Re: [PATCH] phy: rockchip-usb: fix reset control leak
From: Manivannan Sadhasivam
Date: Fri Nov 27 2026 - 08:58:19 EST
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@xxxxxxxxxxxxxxx
Stop CCing stable list for these minor fixes, please.
> 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;
> + }
Why not devm_reset_control_get()?
- Mani