extcon: max77693: cancel cable detection work on detach
Subsystems (3)
PATCH 1/1 extcon: max77693: cancel cable detection work on detach
max77693_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 db1b9037424b ("extcon: MAX77693: Add extcon-max77693 driver to support Maxim MAX77693 MUIC device")
Signed-off-by Hongyan Xu <[email protected]>
--- drivers/extcon/extcon-max77693.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/extcon/extcon-max77693.c +5 -1
@@ -1251,7 +1251,11 @@ static int max77693_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, max77693_muic_detect_cable_wq); + ret =devm_delayed_work_autocancel (&pdev->dev, &info->wq_detcable, + max77693_muic_detect_cable_wq); +if (ret) +return ret; +queue_delayed_work (system_power_efficient_wq, &info->wq_detcable, delay_jiffies);
Signature · 1 line
2.50.1.windows.1