From d9593e5c5802bc9ab20b58da9c5f660788258544 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 12 Jul 2011 09:03:28 +0100 Subject: [PATCH] --- yaml --- r: 262277 b: refs/heads/master c: e80bba4b5108c6479379740201b0a5d9da5ffbac h: refs/heads/master i: 262275: 408ddf53ab99ff2b88627e6bf3cd072bb762be5d v: v3 --- [refs] | 2 +- trunk/drivers/acpi/battery.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index b2011fb066f8..350d92d43260 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9c921c22a7f33397a6774d7fa076db9b6a0fd669 +refs/heads/master: e80bba4b5108c6479379740201b0a5d9da5ffbac diff --git a/trunk/drivers/acpi/battery.c b/trunk/drivers/acpi/battery.c index 40bf01d42cc3..c771768f57c8 100644 --- a/trunk/drivers/acpi/battery.c +++ b/trunk/drivers/acpi/battery.c @@ -986,21 +986,27 @@ static int acpi_battery_add(struct acpi_device *device) #ifdef CONFIG_ACPI_PROCFS_POWER result = acpi_battery_add_fs(device); #endif - if (!result) { - printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", - ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), - device->status.battery_present ? "present" : "absent"); - } else { + if (result) { #ifdef CONFIG_ACPI_PROCFS_POWER acpi_battery_remove_fs(device); #endif - kfree(battery); + goto fail; } + printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", + ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), + device->status.battery_present ? "present" : "absent"); + battery->pm_nb.notifier_call = battery_notify; register_pm_notifier(&battery->pm_nb); return result; + +fail: + sysfs_remove_battery(battery); + mutex_destroy(&battery->lock); + kfree(battery); + return result; } static int acpi_battery_remove(struct acpi_device *device, int type)