Skip to contentSkip to conversation

usb: dwc3: keystone: Fix PHY runtime PM leak on probe errors

PATCH New Felix Gu 2 participants 2 messages Nov 22

Subsystems (2)
lore
Share & tools
lore

Felix Gu

author
#0 lore raw

PATCH 1/1 usb: dwc3: keystone: Fix PHY runtime PM leak on probe errors

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")
---
 drivers/usb/dwc3/dwc3-keystone.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/usb/dwc3/dwc3-keystone.c +5 -4
index 7a5fc8545d4b..7e026f52a823 100644
@@ -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,

Signature · 1 line
Felix Gu <[email protected]>
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines

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")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1