From: Wentao Liang <vulab@iscas.ac.cn>
To: alexandre.torgue@foss.st.com
Cc: andrew+netdev@lunn.ch, clabbe.montjoie@gmail.com,
davem@davemloft.net, edumazet@google.com,
jernej.skrabec@gmail.com, kuba@kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-sunxi@lists.linux.dev, mcoquelin.stm32@gmail.com,
netdev@vger.kernel.org, pabeni@redhat.com, samuel@sholland.org,
wens@kernel.org, Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] net: stmmac: dwmac-sun8i: Fix EPHY clock leak in get_ephy_nodes()
Date: Thu, 17 Sep 2026 11:36:54 +0000 [thread overview]
Message-ID: <20260917113654.2149268-1-vulab@iscas.ac.cn> (raw)
get_ephy_nodes() stores the clock returned by of_clk_get() directly in
gmac->ephy_clk before the reset control is obtained. When the reset
lookup fails, the loop continues or returns without releasing that
clock, and sun8i_dwmac_probe() then jumps to dwmac_remove, which does
not call clk_put(). Keep the clock in a local variable and release it
on the error paths.
Fixes: 634db83b8265 ("net: stmmac: dwmac-sun8i: Handle integrated/external MDIOs")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 48c52eb96233..38d7e71de925 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -783,18 +783,22 @@ static int get_ephy_nodes(struct stmmac_priv *priv)
/* Seek for internal PHY */
for_each_child_of_node_scoped(mdio_internal, iphynode) {
- gmac->ephy_clk = of_clk_get(iphynode, 0);
- if (IS_ERR(gmac->ephy_clk))
+ struct clk *ephy_clk;
+
+ ephy_clk = of_clk_get(iphynode, 0);
+ if (IS_ERR(ephy_clk))
continue;
gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL);
if (IS_ERR(gmac->rst_ephy)) {
ret = PTR_ERR(gmac->rst_ephy);
+ clk_put(ephy_clk);
if (ret == -EPROBE_DEFER) {
of_node_put(mdio_internal);
return ret;
}
continue;
}
+ gmac->ephy_clk = ephy_clk;
dev_info(priv->device, "Found internal PHY node\n");
of_node_put(mdio_internal);
return 0;
--
2.34.1
next reply other threads:[~2026-09-17 11:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 11:36 Wentao Liang [this message]
2026-09-22 12:03 ` [PATCH] net: stmmac: dwmac-sun8i: Fix EPHY clock leak in get_ephy_nodes() Simon Horman
2026-09-23 1:20 ` patchwork-bot+netdevbpf
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=20260917113654.2149268-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=clabbe.montjoie@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jernej.skrabec@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=samuel@sholland.org \
--cc=stable@vger.kernel.org \
--cc=wens@kernel.org \
/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