* [PATCH] ACPI battery: fix possible use after free in acpi_battery_add()
@ 2011-03-26 18:18 Mariusz Kozlowski
0 siblings, 0 replies; only message in thread
From: Mariusz Kozlowski @ 2011-03-26 18:18 UTC (permalink / raw)
To: Len Brown; +Cc: Kyle McMartin, linux-acpi, linux-kernel, Mariusz Kozlowski
When acpi_battery_add_fs() fails 'battery' will be kfreed and then
used again.
Signed-off-by: Mariusz Kozlowski <mk@lab.zgora.pl>
---
drivers/acpi/battery.c | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index fcc13ac..27375e7 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -978,18 +978,15 @@ static int acpi_battery_add(struct acpi_device *device)
acpi_battery_update(battery);
#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 {
-#ifdef CONFIG_ACPI_PROCFS_POWER
+ if (result) {
acpi_battery_remove_fs(device);
-#endif
kfree(battery);
+ return result;
}
-
+#endif
+ 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);
--
1.7.0.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-03-26 18:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-26 18:18 [PATCH] ACPI battery: fix possible use after free in acpi_battery_add() Mariusz Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).