Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: keystone: Fix PHY runtime PM leak on probe errors
@ 2026-11-22 15:15 Felix Gu
  2026-11-22 15:18 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Gu @ 2026-11-22 15:15 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman, Roger Quadros, Felipe Balbi
  Cc: linux-usb, Felix Gu

The phy_reset(), phy_init(), and phy_power_on() error paths returned
without balancing phy_pm_runtime_get_sync(), leaking the PHY runtime PM
usage count.

Route these failures through the common cleanup path so
phy_pm_runtime_put_sync() is always called.

Fixes: 1c11e74e9079 ("usb: dwc3: keystone: Turn on USB3 PHY before controller")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/usb/dwc3/dwc3-keystone.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c
index 7a5fc8545d4b..7e026f52a823 100644
--- a/drivers/usb/dwc3/dwc3-keystone.c
+++ b/drivers/usb/dwc3/dwc3-keystone.c
@@ -108,20 +108,19 @@ static int kdwc3_probe(struct platform_device *pdev)
 	error = phy_reset(kdwc->usb3_phy);
 	if (error < 0) {
 		dev_err(dev, "usb3 phy reset failed: %d\n", error);
-		return error;
+		goto err_put_sync;
 	}
 
 	error = phy_init(kdwc->usb3_phy);
 	if (error < 0) {
 		dev_err(dev, "usb3 phy init failed: %d\n", error);
-		return error;
+		goto err_put_sync;
 	}
 
 	error = phy_power_on(kdwc->usb3_phy);
 	if (error < 0) {
 		dev_err(dev, "usb3 phy power on failed: %d\n", error);
-		phy_exit(kdwc->usb3_phy);
-		return error;
+		goto err_phy_exit;
 	}
 
 	pm_runtime_enable(kdwc->dev);
@@ -164,7 +163,9 @@ static int kdwc3_probe(struct platform_device *pdev)
 	pm_runtime_put_sync(kdwc->dev);
 	pm_runtime_disable(kdwc->dev);
 	phy_power_off(kdwc->usb3_phy);
+err_phy_exit:
 	phy_exit(kdwc->usb3_phy);
+err_put_sync:
 	phy_pm_runtime_put_sync(kdwc->usb3_phy);
 
 	return error;

---
base-commit: adcad7f4e6332cff3d6d7165f41584899f598534
change-id: 20261122-keystone-3da0092b0f37

Best regards,
--  
Felix Gu <ustc.gu@gmail.com>


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

end of thread, other threads:[~2026-11-22 15:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 15:15 [PATCH] usb: dwc3: keystone: Fix PHY runtime PM leak on probe errors Felix Gu
2026-11-22 15:18 ` sashiko-bot

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