[PATCH] extcon: max77843: cancel cable detection work on remove

From: Hongyan Xu

Date: Tue Jul 28 2026 - 03:55:09 EST


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")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Hongyan Xu <getshell@xxxxxxxxxx>
---
drivers/extcon/extcon-max77843.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
index 2ae9f7f1a67..a052d7a9af0 100644
--- a/drivers/extcon/extcon-max77843.c
+++ b/drivers/extcon/extcon-max77843.c
@@ -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);
--
2.50.1.windows.1