mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] phy: rockchip-usb: fix reset control leak
@ 2026-11-15  4:26 Xia Yan
  2026-11-27 13:58 ` Manivannan Sadhasivam
  0 siblings, 1 reply; 3+ messages in thread
From: Xia Yan @ 2026-11-15  4:26 UTC (permalink / raw)
  To: vkoul, linux-phy
  Cc: neil.armstrong, mani, heiko, p.zabel, ayaka, kishon,
	linux-arm-kernel, linux-rockchip, linux-kernel, stable,
	yana06070

rockchip_usb_phy_init() acquires a reset control from each PHY child
node but never releases it on probe failure or driver detach.

The leaked exclusive control prevents a later probe from acquiring
the same reset. Since lookup errors are converted to NULL, subsequent
PHY reset calls silently skip the hardware reset.

Register a devres action after a successful lookup to release the
control on probe failure and detach. Keep the child-node lookup and
the existing handling of lookup errors.

Found during review of reset-control lifetimes.

Fixes: 0f74ab59ce87 ("phy: rockchip-usb: use rockchip_usb_phy_reset to reset phy during wakeup")
Cc: stable@vger.kernel.org
Signed-off-by: Xia Yan <yanxia@cmss.chinamobile.com>
---
 drivers/phy/rockchip/phy-rockchip-usb.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-usb.c b/drivers/phy/rockchip/phy-rockchip-usb.c
index c5a2853a63d3..79b3315b6590 100644
--- a/drivers/phy/rockchip/phy-rockchip-usb.c
+++ b/drivers/phy/rockchip/phy-rockchip-usb.c
@@ -183,6 +183,11 @@ static const struct phy_ops ops = {
 	.owner		= THIS_MODULE,
 };
 
+static void rockchip_usb_phy_reset_put(void *data)
+{
+	reset_control_put(data);
+}
+
 static void rockchip_usb_phy_action(void *data)
 {
 	struct rockchip_usb_phy *rk_phy = data;
@@ -219,8 +224,15 @@ static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base,
 	}
 
 	rk_phy->reset = of_reset_control_get(child, "phy-reset");
-	if (IS_ERR(rk_phy->reset))
+	if (IS_ERR(rk_phy->reset)) {
 		rk_phy->reset = NULL;
+	} else {
+		err = devm_add_action_or_reset(base->dev,
+					       rockchip_usb_phy_reset_put,
+					       rk_phy->reset);
+		if (err)
+			return err;
+	}
 
 	rk_phy->reg_offset = reg_offset;
 

base-commit: 9a0dd2a09484e5ba45eb8e6ab58c0effe18703a3



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

end of thread, other threads:[~2026-12-01  8:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15  4:26 [PATCH] phy: rockchip-usb: fix reset control leak Xia Yan
2026-11-27 13:58 ` Manivannan Sadhasivam
2026-12-01  8:35   ` Xia Yan

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®