mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
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 <[email protected]> Signed-off-by: Anton Vorontsov <[email protected]>
This commit is contained in:
parent
26eb387265
commit
3a2dbd611b
1 changed files with 2 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue