* [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
* Re: [PATCH] phy: rockchip-usb: fix reset control leak
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
0 siblings, 1 reply; 3+ messages in thread
From: Manivannan Sadhasivam @ 2026-11-27 13:58 UTC (permalink / raw)
To: Xia Yan
Cc: vkoul, linux-phy, neil.armstrong, mani, heiko, p.zabel, ayaka,
kishon, linux-arm-kernel, linux-rockchip, linux-kernel, stable,
yana06070
On 2026-11-15 12:26 +0800, Xia Yan wrote:
> 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
Stop CCing stable list for these minor fixes, please.
> 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;
> + }
Why not devm_reset_control_get()?
- Mani
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: rockchip-usb: fix reset control leak
2026-11-27 13:58 ` Manivannan Sadhasivam
@ 2026-12-01 8:35 ` Xia Yan
0 siblings, 0 replies; 3+ messages in thread
From: Xia Yan @ 2026-12-01 8:35 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: vkoul, linux-phy, neil.armstrong, heiko, p.zabel, ayaka, kishon,
linux-arm-kernel, linux-rockchip, linux-kernel, yana06070
Hi Mani,
> Stop CCing stable list for these minor fixes, please.
Understood. I have dropped the stable Cc in v2.
> Why not devm_reset_control_get()?
You're right. devm_phy_create(base->dev, child, &ops) associates the
PHY device with the child node. v2 moves the reset lookup after that
call and uses devm_reset_control_get(&rk_phy->phy->dev, "phy-reset"),
keeping the lookup on the same child node.
This also removes the custom put action from v1. Lookup errors are
still converted to NULL, as before.
v2: https://patchwork.kernel.org/project/linux-phy/patch/20261201082805.50160d227cb63d84.patch@cmss.chinamobile.com/
Thanks,
Xia Yan
^ 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®