Commit 3a2dbd61 authored by Vasiliy Kulikov's avatar Vasiliy Kulikov Committed by Anton Vorontsov

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: default avatarVasiliy Kulikov <segoon@openwall.com>
Signed-off-by: default avatarAnton Vorontsov <cbouatmailru@gmail.com>
parent 26eb3872
...@@ -190,10 +190,10 @@ int power_supply_register(struct device *parent, struct power_supply *psy) ...@@ -190,10 +190,10 @@ int power_supply_register(struct device *parent, struct power_supply *psy)
goto success; goto success;
create_triggers_failed: create_triggers_failed:
device_unregister(psy->dev); device_del(dev);
kobject_set_name_failed: kobject_set_name_failed:
device_add_failed: device_add_failed:
kfree(dev); put_device(dev);
success: success:
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment