Skip to contentSkip to conversation

power: supply: isp1704_charger: cancel work on remove

PATCH Applied Hongyan Xu 2 participants 3 messages Jul 28 – Jul 30

Subsystems (2)
lore
Share & tools
lore

Hongyan Xu

author
#0 lore raw

PATCH 1/1 power: supply: isp1704_charger: cancel work on remove

The USB notifier and initial VBUS detection can schedule isp->work. The remove path unregisters the notifier and power supply, but does not wait for queued or running work before tearing down the power supply state.

Cancel the work after unregistering the notifier. Do this before unregistering the power supply.

This issue was found by a static analysis tool.

---
 drivers/power/supply/isp1704_charger.c | 1 +
 1 file changed, 1 insertion(+)
drivers/power/supply/isp1704_charger.c +1 -0
index 237912a92..e329321d0 100644
@@ -482,6 +482,7 @@ static void isp1704_charger_remove(struct platform_device *pdev)
 	struct isp1704_charger *isp = platform_get_drvdata(pdev);
 
 	usb_unregister_notifier(isp->phy, &isp->nb);
+	cancel_work_sync(&isp->work);
 	power_supply_unregister(isp->psy);
 	isp1704_charger_set_power(isp, 0);
 }
Signature · 1 line
2.50.1.windows.1
#1 lore raw
Quoted 8 lines · Hongyan Xu

The USB notifier and initial VBUS detection can schedule isp->work. The remove path unregisters the notifier and power supply, but does not wait for queued or running work before tearing down the power supply state.

Cancel the work after unregistering the notifier. Do this before unregistering the power supply.

[...]

Applied, thanks!

[1/1] power: supply: isp1704_charger: cancel work on remove

      commit: 60c5b8a9ef4dbc5d69bbc1a960fe55826cb3b643

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>
#2 lore raw

Hi,

Quoted 8 lines · Sebastian Reichel
Quoted 7 lines · Hongyan Xu

The USB notifier and initial VBUS detection can schedule isp->work. The remove path unregisters the notifier and power supply, but does not wait for queued or running work before tearing down the power supply state.

Cancel the work after unregistering the notifier. Do this before unregistering the power supply.

Quoted 6 lines
Quoted 1 line

[...]

Applied, thanks!

[1/1] power: supply: isp1704_charger: cancel work on remove

      commit: 60c5b8a9ef4dbc5d69bbc1a960fe55826cb3b643

I've added a Fixes tag while applying. But considering nobody cared in the last 15 years (bug was in this driver since it exists), it goes the normal route through the next merge window.

Greetings,

-- Sebastian