[PATCH] extcon: max8997: cancel cable detection work on detach

From: Hongyan Xu

Date: Tue Jul 28 2026 - 03:56:02 EST


max8997_muic_probe() queues wq_detcable after the MUIC has been
initialized. The delayed work uses the driver private data and device
resources, but the driver has no remove callback to cancel it. If the
device is detached before the delayed detection runs, the work can run
after the devm-managed data has started going away.

Initialize the delayed work with devm_delayed_work_autocancel() so the
work is synchronously cancelled during device teardown.

This issue was found by a static analysis tool.

Fixes: b76668ba8a77 ("Extcon: add MAX8997 extcon driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Hongyan Xu <getshell@xxxxxxxxxx>
---
drivers/extcon/extcon-max8997.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 9cddf08e069..631da543dee 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -754,7 +754,11 @@ static int max8997_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, max8997_muic_detect_cable_wq);
+ ret = devm_delayed_work_autocancel(&pdev->dev, &info->wq_detcable,
+ max8997_muic_detect_cable_wq);
+ if (ret)
+ return ret;
+
queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,
delay_jiffies);

--
2.50.1.windows.1