Netdev List
 help / color / mirror / Atom feed
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Wanhui Fu <fuwh1120@163.com>,
	heiko@sntech.de, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com,
	david.wu@rock-chips.com
Cc: linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, netdev@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH net] net: stmmac: rk: Fix clock reference leak on probe failure
Date: Wed, 2 Dec 2026 19:56:22 +0100	[thread overview]
Message-ID: <51b51d0f-ecc2-4364-b071-99d61f4ece97@bootlin.com> (raw)
In-Reply-To: <20261201082932.3199297-1-fuwh1120@163.com>

Hi,

On 12/1/26 09:29, Wanhui Fu wrote:
> rk_gmac_clk_init() acquires a clock reference using of_clk_get().
> If the subsequent platform init callback fails, stmmac_dvr_probe()
> returns without calling rk_gmac_exit(), leaking the clock reference.
> 
> Fix this by using devm_get_clk_from_child() and removing the
> explicit clk_put() from rk_gmac_exit().
> 
> Found it by self-developed static analysis tool and compile-test
> passed.
> 
> Fixes: fecd4d7eef8b ("net: stmmac: dwmac-rk: Add integrated PHY support")
> Signed-off-by: Wanhui Fu <fuwh1120@163.com>

This should go to net-next, it's not a regression and only happens in
the failure path, likely not easy to hit in real life.

Please repost,

Maxime

pw-bot: cr

> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index a37df5767d84..82aed5df1eb5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -1168,7 +1168,8 @@ static int rk_gmac_clk_init(struct plat_stmmacenet_data *plat)
>  	}
>  
>  	if (plat->phy_node && bsp_priv->integrated_phy) {
> -		bsp_priv->clk_phy = of_clk_get(plat->phy_node, 0);
> +		bsp_priv->clk_phy = devm_get_clk_from_child(dev,
> +							    plat->phy_node, NULL);
>  		ret = PTR_ERR_OR_ZERO(bsp_priv->clk_phy);
>  		if (ret)
>  			return dev_err_probe(dev, ret, "Cannot get PHY clock\n");
> @@ -1637,14 +1638,10 @@ static int rk_gmac_init(struct device *dev, void *bsp_priv)
>  
>  static void rk_gmac_exit(struct device *dev, void *bsp_priv_)
>  {
> -	struct stmmac_priv *priv = netdev_priv(dev_get_drvdata(dev));
>  	struct rk_priv_data *bsp_priv = bsp_priv_;
>  
>  	rk_gmac_powerdown(bsp_priv);
>  
> -	if (priv->plat->phy_node && bsp_priv->integrated_phy)
> -		clk_put(bsp_priv->clk_phy);
> -
>  	reset_control_put(bsp_priv->phy_reset);
>  }
>  


      reply	other threads:[~2026-12-02 18:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  8:29 [PATCH net] net: stmmac: rk: Fix clock reference leak on probe failure Wanhui Fu
2026-12-02 18:56 ` Maxime Chevallier [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=51b51d0f-ecc2-4364-b071-99d61f4ece97@bootlin.com \
    --to=maxime.chevallier@bootlin.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=david.wu@rock-chips.com \
    --cc=edumazet@kernel.org \
    --cc=fuwh1120@163.com \
    --cc=heiko@sntech.de \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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