[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1290192119-11704-1-git-send-email-segoon@openwall.com>
Date: Fri, 19 Nov 2010 21:41:58 +0300
From: Vasiliy Kulikov <segoon@...nwall.com>
To: kernel-janitors@...r.kernel.org
Cc: Anton Vorontsov <cbou@...l.ru>,
David Woodhouse <dwmw2@...radead.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH] power: power_supply_core: fix use after free and memory leak
device_unregister() might free its argument. This leads to freed
memory use in kfree(). Also use put_device() instead of kfree()
as dev may be already used in another layer after call to device_add().
Signed-off-by: Vasiliy Kulikov <segoon@...nwall.com>
---
Compile tested only.
drivers/power/power_supply_core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 91606bb..f06bad0 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -190,10 +190,10 @@ int power_supply_register(struct device *parent, struct power_supply *psy)
goto success;
create_triggers_failed:
- device_unregister(psy->dev);
+ device_del(dev);
kobject_set_name_failed:
device_add_failed:
- kfree(dev);
+ put_device(dev);
success:
return rc;
}
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists