Skip to contentSkip to conversation

extcon: max14577: Fix potential use-after-free on removal

PATCH New Guangshuo Li 1 participant 1 message Nov 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extcon: max14577: Fix potential use-after-free on removal

Probe queues delayed cable detection, but removal does not cancel it. The worker can therefore run after the device resources and private data have been released.

Use managed delayed work so cable detection is cancelled before its extcon device and private data are released.

This issue was found by our static analysis tool under development.

Fixes 962e56bfcf0b ("extcon: max14577: Add extcon-max14577 driver to support MUIC device")
---
 drivers/extcon/extcon-max14577.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/extcon/extcon-max14577.c +4 -1
index 7eefc13e9f59..dc13f1997f41 100644
@@ -763,7 +763,10 @@ static int max14577_muic_probe(struct platform_device *pdev)
 	 * After completing the booting of platform, the extcon provider
 	 * driver should notify cable state to upper layer.
 	 */
-	INIT_DELAYED_WORK(&info->wq_detcable, max14577_muic_detect_cable_wq);
+	ret = devm_delayed_work_autocancel(&pdev->dev, &info->wq_detcable,
+					   max14577_muic_detect_cable_wq);
+	if (ret)
+		return ret;
 	queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,
 			delay_jiffies);
 

base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5

Signature · 1 line
2.43.0