extcon: max8997: cancel cable detection work on detach
Subsystems (2)
PATCH 1/1 extcon: max8997: cancel cable detection work on detach
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")
Signed-off-by Hongyan Xu <[email protected]>
--- drivers/extcon/extcon-max8997.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/extcon/extcon-max8997.c +5 -1
@@ -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);
Signature · 1 line
2.50.1.windows.1