net: ethernet: stmmac: dwmac-rk: fix bulk clock leak when the PHY clock fails
Subsystems (5)
PATCH v2 1/1 net: ethernet: stmmac: dwmac-rk: fix bulk clock leak when the PHY clock fails
gmac_clk_enable() enables the bulk clocks first and then the optional PHY clock. If clk_prepare_enable() on the PHY clock fails, the function returns without rolling back the bulk clocks, and bsp_priv->clk_enabled stays false, so the later gmac_clk_enable(bsp_priv, false) becomes a no-op and the bulk clock references are leaked.
Add the missing clk_bulk_disable_unprepare() on that failure path.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +4 -1
@@ -1162,8 +1162,11 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)return ret; ret =clk_prepare_enable (bsp_priv->clk_phy); -if (ret) +if (ret) { +clk_bulk_disable_unprepare (bsp_priv->num_clks, + bsp_priv->clks);return ret; + }rk_configure_io_clksel (bsp_priv);rk_ungate_rmii_clock (bsp_priv);
Signature · 1 line
2.47.3
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 9 lines · On Wed, 23 Sep 2026 20:37:13 +0800 you wrote:
gmac_clk_enable()enables the bulk clocks first and then the optional PHY clock. Ifclk_prepare_enable()on the PHY clock fails, the function returns without rolling back the bulk clocks, andbsp_priv->clk_enabledstays false, so the latergmac_clk_enable(bsp_priv, false)becomes a no-op and the bulk clock references are leaked.Add the missing
clk_bulk_disable_unprepare()on that failure path.[...]
Here is the summary with links:
- [net,v2] net: ethernet: stmmac: dwmac-rk: fix bulk clock leak when the PHY clock fails
https://git.kernel.org/netdev/net/c/8db67bb6a1ff
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html