Skip to content

Commit 06615d1

Browse files
bluesheep1337sre
authored andcommitted
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: c1a281e ("power: Add support for DA9150 Charger") Signed-off-by: Zheng Wang <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 47c29d6 commit 06615d1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/power/supply/da9150-charger.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ static int da9150_charger_remove(struct platform_device *pdev)
657657

658658
if (!IS_ERR_OR_NULL(charger->usb_phy))
659659
usb_unregister_notifier(charger->usb_phy, &charger->otg_nb);
660+
cancel_work_sync(&charger->otg_work);
660661

661662
power_supply_unregister(charger->battery);
662663
power_supply_unregister(charger->usb);

0 commit comments

Comments
 (0)