lkml.org 
[lkml]   [2011]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] Battery: sysfs_remove_battery(): possible circular locking
    From
    Date
    I think changing  'the marker' to 'battery->bat.name' will introduce
    problem.
    In the sysfs_add_battery(), when the 'battery->bat.name' is assigned,
    the power_supply_register() and device_create_file() have not been
    invoked. In this time, maybe sysfs_remove_battery() will be invoked and
    cause device_remove_file() and power_supply_unregister() invoked without
    device file created and power supply registered.

    sysfs_remove_battery() will be invoked in the battery_notify(),
    acpi_battery_refresh() and sysfs_remove_battery() which causes the
    situation. This is also the cause of bug 35642.

    > I've changed `the marker' from `battery->bat.dev' to `battery->bat.name', so
    > the basic idea should remain the same, now we just can release battery->lock
    > more quicker, before device_remove_file() call.
    >
    > Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
    >
    > ---
    >
    > drivers/acpi/battery.c | 6 ++++--
    > 1 files changed, 4 insertions(+), 2 deletions(-)
    >
    > diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
    > index 87c0a8d..398cbfb 100644
    > --- a/drivers/acpi/battery.c
    > +++ b/drivers/acpi/battery.c
    > @@ -574,15 +574,17 @@ static int sysfs_add_battery(struct acpi_battery *battery)
    > static void sysfs_remove_battery(struct acpi_battery *battery)
    > {
    > mutex_lock(&battery->lock);
    > - if (!battery->bat.dev) {
    > + if (!battery->bat.name) {
    > mutex_unlock(&battery->lock);
    > return;
    > }
    >
    > + battery->bat.name = NULL;
    > + mutex_unlock(&battery->lock);
    > +
    > device_remove_file(battery->bat.dev, &alarm_attr);
    > power_supply_unregister(&battery->bat);
    > battery->bat.dev = NULL;
    > - mutex_unlock(&battery->lock);
    > }
    >
    > /*
    >




    \
     
     \ /
      Last update: 2011-08-05 07:15    [W:0.025 / U:0.356 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site