[PATCH] usb: dwc3: am62: Fix runtime PM usage count leak on probe error path

Radhey Shyam Pandey posted 1 patch 3 weeks, 2 days ago
drivers/usb/dwc3/dwc3-am62.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] usb: dwc3: am62: Fix runtime PM usage count leak on probe error path
Posted by Radhey Shyam Pandey 3 weeks, 2 days ago
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
Re: [PATCH] usb: dwc3: am62: Fix runtime PM usage count leak on probe error path
Posted by Thinh Nguyen 3 weeks ago
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