diff options
author | Vasiliy Kulikov <segoon@openwall.com> | 2010-11-19 13:41:58 -0500 |
---|---|---|
committer | Anton Vorontsov <cbouatmailru@gmail.com> | 2010-12-21 18:39:55 -0500 |
commit | 3a2dbd611b38cf9a026c0099a85701ad183d1949 (patch) | |
tree | b6d181ab33effdcd0e0466ee583c0e224563e372 /drivers/power | |
parent | 26eb387265872b59566ddeed5e9bf142a6b9ff5b (diff) |
power_supply: 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@openwall.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | 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 91606bb55318..f06bad047d76 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) | |||
190 | goto success; | 190 | goto success; |
191 | 191 | ||
192 | create_triggers_failed: | 192 | create_triggers_failed: |
193 | device_unregister(psy->dev); | 193 | device_del(dev); |
194 | kobject_set_name_failed: | 194 | kobject_set_name_failed: |
195 | device_add_failed: | 195 | device_add_failed: |
196 | kfree(dev); | 196 | put_device(dev); |
197 | success: | 197 | success: |
198 | return rc; | 198 | return rc; |
199 | } | 199 | } |