All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Cong Nguyen" <congnt264@gmail.com>
Cc: linux-phy@lists.infradead.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH] phy: mapphone-mdm6600: cancel delayed work on probe error
Date: Mon, 30 Nov 2026 05:19:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-240395@kernel.org> (raw)
In-Reply-To: <20261130050848.688913-1-congnt264@gmail.com>

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

      reply	other threads:[~2026-11-30  5:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  5:08 [PATCH] phy: mapphone-mdm6600: cancel delayed work on probe error Cong Nguyen
2026-11-30  5:08 ` Cong Nguyen
2026-11-30  5:19 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-240395@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=congnt264@gmail.com \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.