mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] mdio-airoha: fix refcount leak in airoha_mdio_probe()
Date: Tue, 9 Jun 2026 11:47:05 +0200	[thread overview]
Message-ID: <a3757265-9487-4f75-9bdf-dcb38dff4022@lunn.ch> (raw)
In-Reply-To: <20260609090729.219120-1-vulab@iscas.ac.cn>

On Tue, Jun 09, 2026 at 09:07:29AM +0000, Wentao Liang wrote:
> In airoha_mdio_probe(), after calling reset_control_deassert(),
> if clk_set_rate() fails, the function returns immediately without
> calling reset_control_assert().  This leaves the reset line
> deasserted and causes a reference count leak on shared reset
> controllers.  The devm cleanup does not assert the reset line, so
> the unbalanced deassert persists.
> 
> Fix this by adding a reset_control_assert() call on the
> clk_set_rate() error path, matching the existing error handling
> for devm_of_mdiobus_register().
> 
> Cc: stable@vger.kernel.org
> Fixes: 67e3ba978361 ("net: mdio: Add MDIO bus controller for Airoha AN7583")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/net/mdio/mdio-airoha.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mdio/mdio-airoha.c b/drivers/net/mdio/mdio-airoha.c
> index 52e7475121ea..030482b8318f 100644
> --- a/drivers/net/mdio/mdio-airoha.c
> +++ b/drivers/net/mdio/mdio-airoha.c
> @@ -245,8 +245,10 @@ static int airoha_mdio_probe(struct platform_device *pdev)
>  		freq = 2500000;
>  
>  	ret = clk_set_rate(priv->clk, freq);
> -	if (ret)
> +	if (ret) {
> +		reset_control_assert(priv->reset);
>  		return ret;
> +	}
>  
>  	ret = devm_of_mdiobus_register(dev, bus, dev->of_node);
>  	if (ret) {

devm_of_mdiobus_register() also calls reset_control_assert() on
error. So please put all the error cleanup handling at the end and use
goto.

    Andrew

---
pw-bot: cr

      reply	other threads:[~2026-06-09  9:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09  9:07 Wentao Liang
2026-06-09  9:47 ` Andrew Lunn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a3757265-9487-4f75-9bdf-dcb38dff4022@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=vulab@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®