Skip to contentSkip to conversation

net: stmmac: rk: put the PHY clock on remove

PATCH Applied Russell King (Oracle) 3 participants 3 messages Aug 8, 2025 – Aug 12, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: stmmac: rk: put the PHY clock on remove

The PHY clock (bsp_priv->clk_phy) is obtained using of_clk_get(), which doesn't take part in the devm release. Therefore, when a device is unbound, this clock needs to be explicitly put. Fix this.

---
Spotted this resource leak while making other changes to dwmac-rk. Would be great if the dwmac-rk maintainers can test it.

v2: fix build error

 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +5 -1
index 79b92130a03f..f6687c2f30f6 100644
@@ -1765,11 +1765,15 @@ static int rk_gmac_probe(struct platform_device *pdev)
 
 static void rk_gmac_remove(struct platform_device *pdev)
 {
-	struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(&pdev->dev);
+	struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev));
+	struct rk_priv_data *bsp_priv = priv->plat->bsp_priv;
 
 	stmmac_dvr_remove(&pdev->dev);
 
 	rk_gmac_powerdown(bsp_priv);
+
+	if (priv->plat->phy_node && bsp_priv->integrated_phy)
+		clk_put(bsp_priv->clk_phy);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.30.2
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Russell King (Oracle)

The PHY clock (bsp_priv->clk_phy) is obtained using of_clk_get(), which doesn't take part in the devm release. Therefore, when a device is unbound, this clock needs to be explicitly put. Fix this.

---
Spotted this resource leak while making other changes to dwmac-rk. Would be great if the dwmac-rk maintainers can test it.

v2: fix build error

Thanks for the update Russell.

This fix looks good to me.

And I guess it ought to be marked with.

Fixes fecd4d7eef8b ("net: stmmac: dwmac-rk: Add integrated PHY support")

If correct, then I don't think any further action is required as supplying tags via email should be sufficient.

#2 lore raw
In reply to Russell King (Oracle)
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 08 Aug 2025 13:16:34 +0100 you wrote:

The PHY clock (bsp_priv->clk_phy) is obtained using of_clk_get(), which doesn't take part in the devm release. Therefore, when a device is unbound, this clock needs to be explicitly put. Fix this.

---
Spotted this resource leak while making other changes to dwmac-rk. Would be great if the dwmac-rk maintainers can test it.

[...]

Here is the summary with links:
- [net,v2] net: stmmac: rk: put the PHY clock on remove

    https://git.kernel.org/netdev/net/c/de1e963ad064

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html