* [PATCH] phy: mapphone-mdm6600: cancel delayed work on probe error
@ 2026-11-30 5:08 Cong Nguyen
2026-11-30 5:19 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Cong Nguyen @ 2026-11-30 5:08 UTC (permalink / raw)
To: Vinod Koul
Cc: Neil Armstrong, Manivannan Sadhasivam, Tony Lindgren, linux-phy,
linux-kernel
phy_mdm6600_probe() queues bootup_work before it can fail, and the
status IRQ and runtime resume queue status_work and modem_wake_work.
If a later step fails, the probe error path does not cancel them, and
they can run after the devres-managed ddata is freed.
Cancel the three works in the error path, as phy_mdm6600_remove() does.
Fixes: 2ad2af081622 ("phy: mapphone-mdm6600: Improve phy related runtime PM calls")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
drivers/phy/motorola/phy-mapphone-mdm6600.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/phy/motorola/phy-mapphone-mdm6600.c b/drivers/phy/motorola/phy-mapphone-mdm6600.c
index ff364a990187..9f3a81992c0e 100644
--- a/drivers/phy/motorola/phy-mapphone-mdm6600.c
+++ b/drivers/phy/motorola/phy-mapphone-mdm6600.c
@@ -624,6 +624,9 @@ static int phy_mdm6600_probe(struct platform_device *pdev)
phy_mdm6600_device_power_off(ddata);
pm_runtime_disable(ddata->dev);
pm_runtime_dont_use_autosuspend(ddata->dev);
+ cancel_delayed_work_sync(&ddata->modem_wake_work);
+ cancel_delayed_work_sync(&ddata->bootup_work);
+ cancel_delayed_work_sync(&ddata->status_work);
}
return error;
--
2.25.1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] phy: mapphone-mdm6600: cancel delayed work on probe error
2026-11-30 5:08 [PATCH] phy: mapphone-mdm6600: cancel delayed work on probe error Cong Nguyen
@ 2026-11-30 5:19 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-30 5:19 UTC (permalink / raw)
To: Cong Nguyen; +Cc: linux-phy, vkoul, neil.armstrong, olteanv
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] phy: mapphone-mdm6600: work cancelled after power off in
phy_mdm6600_probe()
- [Medium] phy: mapphone-mdm6600: status_work re-queued after cancel in
probe error path
--
commit b4160623090b46c5f1cb5b5afc4c4f7d6976ee19
Author: Cong Nguyen <congnt264@gmail.com>
phy: mapphone-mdm6600: cancel delayed work on probe error
This commit cancels modem_wake_work, bootup_work, and status_work in the
error path of phy_mdm6600_probe().
> diff --git a/drivers/phy/motorola/phy-mapphone-mdm6600.c b/drivers/phy/motorola/phy-mapphone-mdm6600.c
> index fd0e0cd1c1cfb..556d9ed7686bb 100644
> --- a/drivers/phy/motorola/phy-mapphone-mdm6600.c
> +++ b/drivers/phy/motorola/phy-mapphone-mdm6600.c
> @@ -624,6 +624,9 @@ static int phy_mdm6600_probe(struct platform_device *pdev)
> phy_mdm6600_device_power_off(ddata);
> pm_runtime_disable(ddata->dev);
> pm_runtime_dont_use_autosuspend(ddata->dev);
> + cancel_delayed_work_sync(&ddata->modem_wake_work);
> + cancel_delayed_work_sync(&ddata->bootup_work);
> + cancel_delayed_work_sync(&ddata->status_work);
[Severity: Medium]
Should runtime PM be disabled and modem_wake_work and bootup_work be
cancelled before phy_mdm6600_device_power_off()?
phy_mdm6600_probe() schedules bootup_work and sleeps for 4500 ms before
waking the modem via pm_runtime_get_sync() (which schedules the
self-rearming modem_wake_work every 600 ms). Meanwhile, bootup_work
sleeps for 4200 ms in phy_mdm6600_device_power_on() and then waits on
ddata->ack for up to 8000 ms.
If devm_phy_create() or devm_of_phy_provider_register() fails,
phy_mdm6600_device_power_off() runs while both works are still active:
CPU0 (probe error) kworker (bootup_work)
phy_mdm6600_device_power_off() phy_mdm6600_device_power_on()
ddata->enabled = false;
phy_mdm6600_cmd(...SHUTDOWN_REQ)
wait_for_completion_timeout(&ddata->ack, ...)
wait_for_completion_timeout(&ddata->ack, ...)
/* consumes shutdown ack */
devm_request_threaded_irq(... "mdm6600-wake" ...)
ddata->running = true;
/* times out after 5000 ms */
pinctrl_pm_select_sleep_state()
At the same time, modem_wake_work continues toggling mode_gpio0 to wake
the modem while it is shutting down.
[Severity: Medium]
Can phy_mdm6600_irq_thread() re-queue status_work after
cancel_delayed_work_sync(&ddata->status_work) returns?
The status GPIO IRQs are registered with devm_request_threaded_irq() in
phy_mdm6600_init_irq(), so they remain active until devres teardown runs
after phy_mdm6600_probe() returns:
CPU0 CPU1 (irq/mdm6600)
phy_mdm6600_probe()
cancel_delayed_work_sync(&ddata->status_work)
phy_mdm6600_irq_thread()
schedule_delayed_work(&ddata->status_work, ...)
return error;
devres_release_all()
/* frees IRQs and ddata */
phy_mdm6600_status()
ddata->status_gpios <-- use-after-free
Using disable_delayed_work_sync() (or devm_delayed_work_autocancel())
would prevent status_work from being re-scheduled before the devm IRQs are
freed.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130050848.688913-1-congnt264@gmail.com?part=1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-30 5:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 5:08 [PATCH] phy: mapphone-mdm6600: cancel delayed work on probe error Cong Nguyen
2026-11-30 5:19 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox