[PATCH] phy: rockchip-usb: fix reset control leak
From: Xia Yan
Date: Sat Nov 14 2026 - 23:27:03 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Xia Yan <yanxia@xxxxxxxxxxxxxxxxxxxx>
---
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