mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
power: supply: da9150: Fix use after free bug in da9150_charger_remove due to race condition
In da9150_charger_probe, &charger->otg_work is bound with
da9150_charger_otg_work. da9150_charger_otg_ncb may be
called to start the work.
If we remove the module which will call da9150_charger_remove
to make cleanup, there may be a unfinished work. The possible
sequence is as follows:
Fix it by canceling the work before cleanup in the da9150_charger_remove
CPU0 CPUc1
|da9150_charger_otg_work
da9150_charger_remove |
power_supply_unregister |
device_unregister |
power_supply_dev_release|
kfree(psy) |
|
| power_supply_changed(charger->usb);
| //use
Fixes: c1a281e34d
("power: Add support for DA9150 Charger")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
47c29d6921
commit
06615d11cc
@ -657,6 +657,7 @@ static int da9150_charger_remove(struct platform_device *pdev)
|
||||
|
||||
if (!IS_ERR_OR_NULL(charger->usb_phy))
|
||||
usb_unregister_notifier(charger->usb_phy, &charger->otg_nb);
|
||||
cancel_work_sync(&charger->otg_work);
|
||||
|
||||
power_supply_unregister(charger->battery);
|
||||
power_supply_unregister(charger->usb);
|
||||
|
Loading…
Reference in New Issue
Block a user