mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: am62: Fix runtime PM usage count leak on probe error path
@ 2026-09-02 14:54 Radhey Shyam Pandey
  2026-09-05  0:21 ` Thinh Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Radhey Shyam Pandey @ 2026-09-02 14:54 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman, Aswath Govindraju, Roger Quadros
  Cc: linux-usb, linux-kernel, stable, Radhey Shyam Pandey

dwc3_ti_probe() takes a runtime PM reference with pm_runtime_get_noresume()
before creating the dwc3 core child device, and releases it with
pm_runtime_put_autosuspend() once probe has succeeded. The err_pm_disable
error path only disables runtime PM, so the reference taken a few lines
earlier is never dropped.

The usage counter lives in struct device and is not reset when the driver
is unbound, so the leaked reference outlives the failed probe. If the
device is probed again, through a manual rebind or a module reload, the
counter starts at one instead of zero and the pm_runtime_put_autosuspend()
on the success path can no longer bring it back down. The wrapper then
stays runtime resumed for good and autosuspend never kicks in.

Drop the reference before disabling runtime PM, matching the ordering
already used in dwc3_ti_remove().

Fixes: e8784c0aec03 ("drivers: usb: dwc3: Add AM62 USB wrapper driver")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
---
 drivers/usb/dwc3/dwc3-am62.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
index 632634d6e81e..d03b3950ce04 100644
--- a/drivers/usb/dwc3/dwc3-am62.c
+++ b/drivers/usb/dwc3/dwc3-am62.c
@@ -299,6 +299,7 @@ static int dwc3_ti_probe(struct platform_device *pdev)
 
 err_pm_disable:
 	clk_disable_unprepare(am62->usb2_refclk);
+	pm_runtime_put_noidle(dev);
 	pm_runtime_disable(dev);
 	pm_runtime_set_suspended(dev);
 	return ret;

---
base-commit: 8b72f6626dc39b9e7e82b2721d4f7c3b86286012
change-id: 20260902-dwc3-am62-rpm-fix-514ccf0696a3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: dwc3: am62: Fix runtime PM usage count leak on probe error path
  2026-09-02 14:54 [PATCH] usb: dwc3: am62: Fix runtime PM usage count leak on probe error path Radhey Shyam Pandey
@ 2026-09-05  0:21 ` Thinh Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Thinh Nguyen @ 2026-09-05  0:21 UTC (permalink / raw)
  To: Radhey Shyam Pandey
  Cc: Thinh Nguyen, Greg Kroah-Hartman, Aswath Govindraju,
	Roger Quadros, linux-usb, linux-kernel, stable

On Wed, Sep 02, 2026, Radhey Shyam Pandey wrote:
> dwc3_ti_probe() takes a runtime PM reference with pm_runtime_get_noresume()
> before creating the dwc3 core child device, and releases it with
> pm_runtime_put_autosuspend() once probe has succeeded. The err_pm_disable
> error path only disables runtime PM, so the reference taken a few lines
> earlier is never dropped.
> 
> The usage counter lives in struct device and is not reset when the driver
> is unbound, so the leaked reference outlives the failed probe. If the
> device is probed again, through a manual rebind or a module reload, the
> counter starts at one instead of zero and the pm_runtime_put_autosuspend()
> on the success path can no longer bring it back down. The wrapper then
> stays runtime resumed for good and autosuspend never kicks in.
> 
> Drop the reference before disabling runtime PM, matching the ordering
> already used in dwc3_ti_remove().
> 
> Fixes: e8784c0aec03 ("drivers: usb: dwc3: Add AM62 USB wrapper driver")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
> ---
>  drivers/usb/dwc3/dwc3-am62.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
> index 632634d6e81e..d03b3950ce04 100644
> --- a/drivers/usb/dwc3/dwc3-am62.c
> +++ b/drivers/usb/dwc3/dwc3-am62.c
> @@ -299,6 +299,7 @@ static int dwc3_ti_probe(struct platform_device *pdev)
>  
>  err_pm_disable:
>  	clk_disable_unprepare(am62->usb2_refclk);
> +	pm_runtime_put_noidle(dev);
>  	pm_runtime_disable(dev);
>  	pm_runtime_set_suspended(dev);
>  	return ret;
> 
> ---
> base-commit: 8b72f6626dc39b9e7e82b2721d4f7c3b86286012
> change-id: 20260902-dwc3-am62-rpm-fix-514ccf0696a3
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

BR,
Thinh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-05  0:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-02 14:54 [PATCH] usb: dwc3: am62: Fix runtime PM usage count leak on probe error path Radhey Shyam Pandey
2026-09-05  0:21 ` Thinh Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®