Skip to content

Commit f38092b

Browse files
committed
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: Battery: sysfs_remove_battery(): possible circular locking
2 parents 4b00e4b + 5389102 commit f38092b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/acpi/battery.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ enum {
9999

100100
struct acpi_battery {
101101
struct mutex lock;
102+
struct mutex sysfs_lock;
102103
struct power_supply bat;
103104
struct acpi_device *device;
104105
struct notifier_block pm_nb;
@@ -573,16 +574,16 @@ static int sysfs_add_battery(struct acpi_battery *battery)
573574

574575
static void sysfs_remove_battery(struct acpi_battery *battery)
575576
{
576-
mutex_lock(&battery->lock);
577+
mutex_lock(&battery->sysfs_lock);
577578
if (!battery->bat.dev) {
578-
mutex_unlock(&battery->lock);
579+
mutex_unlock(&battery->sysfs_lock);
579580
return;
580581
}
581582

582583
device_remove_file(battery->bat.dev, &alarm_attr);
583584
power_supply_unregister(&battery->bat);
584585
battery->bat.dev = NULL;
585-
mutex_unlock(&battery->lock);
586+
mutex_unlock(&battery->sysfs_lock);
586587
}
587588

588589
/*
@@ -982,6 +983,7 @@ static int acpi_battery_add(struct acpi_device *device)
982983
strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
983984
device->driver_data = battery;
984985
mutex_init(&battery->lock);
986+
mutex_init(&battery->sysfs_lock);
985987
if (ACPI_SUCCESS(acpi_get_handle(battery->device->handle,
986988
"_BIX", &handle)))
987989
set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
@@ -1010,6 +1012,7 @@ static int acpi_battery_add(struct acpi_device *device)
10101012
fail:
10111013
sysfs_remove_battery(battery);
10121014
mutex_destroy(&battery->lock);
1015+
mutex_destroy(&battery->sysfs_lock);
10131016
kfree(battery);
10141017
return result;
10151018
}
@@ -1027,6 +1030,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
10271030
#endif
10281031
sysfs_remove_battery(battery);
10291032
mutex_destroy(&battery->lock);
1033+
mutex_destroy(&battery->sysfs_lock);
10301034
kfree(battery);
10311035
return 0;
10321036
}

0 commit comments

Comments
 (0)