Skip to contentSkip to conversation

extcon: max77843: cancel cable detection work on remove

PATCH New Hongyan Xu 1 participant 1 message Jul 28

Subsystems (3)
lore
Share & tools
lore

Hongyan Xu

author
#0 lore raw

PATCH 1/1 extcon: max77843: cancel cable detection work on remove

max77843_muic_probe() queues wq_detcable after requesting the MUIC IRQs. max77843_muic_remove() cancels irq_work, but it leaves the delayed cable detection work pending while tearing down the MUIC IRQ chip and I2C client. A delayed work item that runs after remove can dereference the driver private data and removed resources.

Cancel wq_detcable synchronously at the start of remove, before tearing down the resources used by the worker.

This issue was found by a static analysis tool.

Fixes 27a28d32b4f2 ("extcon: max77843: Add max77843 MUIC driver")
---
 drivers/extcon/extcon-max77843.c | 1 +
 1 file changed, 1 insertion(+)
drivers/extcon/extcon-max77843.c +1 -0
index 2ae9f7f1a67..a052d7a9af0 100644
@@ -933,6 +933,7 @@ static void max77843_muic_remove(struct platform_device *pdev)
 	struct max77843_muic_info *info = platform_get_drvdata(pdev);
 	struct max77693_dev *max77843 = info->max77843;
 
+	cancel_delayed_work_sync(&info->wq_detcable);
 	cancel_work_sync(&info->irq_work);
 	regmap_del_irq_chip(max77843->irq, max77843->irq_data_muic);
 	i2c_unregister_device(max77843->i2c_muic);
Signature · 1 line
2.50.1.windows.1