Article View: linux.kernel.netdev
Article #26605Re: [PATCH net] net: stmmac: rk: Fix clock reference leak on probe failure
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 23:31
Date: Thu, 03 Dec 2026 23:31
140 lines
12630 bytes
12630 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The patch is incomplete.
- [Low] The patch silently fixes a crash that the commit message never
mentions.
--
net: stmmac: rk: Fix clock reference leak on probe failure
This patch changes rk_gmac_clk_init() to get the integrated PHY clock
with devm_get_clk_from_child() instead of of_clk_get(). It also drops
the matching clk_put() from rk_gmac_exit(). The goal is to stop leaking
the clock reference when the platform init callback fails in
stmmac_dvr_probe().
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index a37df5767d84e..67561252224ae 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
[ ... ]
> @@ -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);
> -
[Severity: Low]
This isn't a bug, but removing this dereference also changes behavior in
a way the commit message doesn't mention.
stmmac_dvr_probe() calls ->exit() whenever __stmmac_dvr_probe() fails:
ret = __stmmac_dvr_probe(dev, plat_dat, res);
if (ret && plat_dat->exit)
plat_dat->exit(dev, plat_dat->bsp_priv);
Some of those failures happen before __stmmac_dvr_probe() reaches
dev_set_drvdata(device, priv->dev):
- an invalid DMA config
- a devm_alloc_etherdev_mqs() allocation failure
- a devm_netdev_alloc_pcpu_stats() allocation failure
- a stmmac_msi_init() failure
In those cases drvdata is still NULL. The old rk_gmac_exit() then
computed netdev_priv(NULL) and read priv->plat, which would fault.
That dereference came from 1a62894e040d ("net: stmmac: rk: convert to
init()/exit() methods"), not from fecd4d7eef8b.
Could the commit message say that this also fixes an oops on early probe
failure? A Fixes: tag for 1a62894e040d would also show stable
backporters which trees need it.
> reset_control_put(bsp_priv->phy_reset);
> }
[Severity: High]
Does bsp_priv->phy_reset still leak on the same failure path the commit
message describes?
rk_gmac_setup() takes phy_reset with the non-devm, exclusive getter. It
does this under the same integrated_phy condition as clk_phy, and both
came from fecd4d7eef8b:
rk_gmac_setup() {
...
if (bsp_priv->integrated_phy) {
bsp_priv->phy_reset = of_reset_control_get(plat->phy_node, NULL);
...
}
rk_gmac_exit() is still the only place that releases it at runtime. When
rk_gmac_init() fails, stmmac_dvr_probe() returns without calling
->exit():
stmmac_dvr_probe() {
if (plat_dat->init) {
ret = plat_dat->init(dev, plat_dat->bsp_priv);
if (ret)
return ret;
}
...
}
The same thing happens when rk_gmac_clk_init() fails in
rk_gmac_probe(). That includes -EPROBE_DEFER from
devm_clk_bulk_get_optional() or from the new devm_get_clk_from_child():
rk_gmac_probe() {
...
ret = rk_gmac_clk_init(plat_dat);
if (ret)
return ret;
...
}
On the next probe attempt, could __reset_control_get_internal() find
the leaked exclusive reset control and hit this?
if (WARN_ON(!rstc->shared || !shared))
return ERR_PTR(-EBUSY);
If so, rk_gmac_setup() would print "No PHY reset control found." and set
phy_reset to NULL.
With phy_reset NULL, rk_gmac_integrated_ephy_powerup() skips its whole
if (priv->phy_reset) block. That block holds the only write of
RK_MACPHY_ENABLE. rk_gmac_integrated_ephy_powerdown() still writes
RK_MACPHY_DISABLE.
After the first powerdown (suspend or remove), would the integrated PHY
then stay disabled?
Could phy_reset also be devm-managed here, for example with a devm
reset getter or devm_add_action_or_reset()? That would cover both
integrated PHY resources on these failure paths.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201082932.3199297-1-fuwh1120%40163.com
Technical Details
Message-ID:
<179634071959.3146.8780794952618737741@kernel.org>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376903-linux-kernel-netdev=dewy.ruReferences:
<20261201082932.3199297-1-fuwh1120@163.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376903-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net: stmmac: rk: Fix clock reference leak on probe failure Date: Thu, 03 Dec 2026 23:31:59 +0000 Organization: Usenet Network Message-ID: <179634071959.3146.8780794952618737741@kernel.org> References: <20261201082932.3199297-1-fuwh1120@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2628087"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:6hKEcieyKQ7BbBPbR7MmOT8AxaE= sha256:pNF8z9X/Yf7dnXYVIna3UZWTHkZ3RyCzsd6/ewsaymY= sha1:As13wlihbec/bUol5Gx1dLYY/+8= sha256:6xgNgGK+lmHb2E8gBZx4eC4XL/EprP1PPCwak8taC54= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id A8607117A57; Fri, 4 Dec 2026 02:32:25 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.64 X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vCxnvvFtRk9Q; Fri, 4 Dec 2026 02:32:18 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376903-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id A9019117A35; Fri, 4 Dec 2026 02:32:08 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 03B5227D40; Thu, 3 Dec 2026 23:32:03 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796340722; b=nCqJAHOrE0BQYVVy0HFTPR3Lj+gpI2k5MycM+2q4E3loR3I0yA8tIo8LJD3vhCUfPGKz kiQrVZpsgt/2s8/NzbTivplHOWj13s6iGTF9xvVgQH0Pe2tdUyCAhgQNzkA2qnYZpW/6o zMJndmjzWAfmZmsr6CHS5HJiQhZqoRpd65wWPRkfeEqU/9oMNJuwmP1PpQ4GVxcB5L5Co LIxGlRsBD25vwnZZvVFLEBbt4CdUDydYVz9YrDP4ni3Hw3r/M++wpQTQG64k29vTZHvzl oP9bB1dU1F/v95QmpyEfzJm1PIo0CfcYrgnRuMi7MRAMJJK8iocN9/hbJrHstNO0PSQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796340722; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=oJJRqXQ7Gdc6Ta9X01M0xRcgHig87hhCiiqIVEyMMFg=; b=SFWIneu9taOGyBaX8PIGthXB+ZEaOLrUdHtccRDgDcfAWM2YJrloS7tD3pSO6Dz+4HI6 4etXekel5DkgjQITy9gqMpS4uVNKZI3mzuXAcnNJkt0qubh6G6WEC3KPJRa9XFSaOioVz OBvRGcZ5nL/n9AKP55a3XKCjLKtI39cDWPRFhtlaVlApsT1ckeVNwU2crM+hBVyCm91k/ i1QmOxsIPLl7dCr9Jq0jfM6YeMB/cpEfbgnA7Lz5c71V/+t6UFf9g3i9/vAU9eJm9dRW2 aUh+Ie+du1s4gSBPnY+9XursR/QGxRsDKCKqvB4dK9fD4UZP0hMza9/9HrLvce6jSWA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i8cR6dDk; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E9E2606A333; Thu, 3 Dec 2026 23:32:02 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i8cR6dDk X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796340721; b=2aJnpxnZIdB5RZtKlnI1lDZsIoCTjJqEt5aNMtR0+YmfWW2tnIQSEwZgqwherMXnnkTd 4NcbdHZXlSVeazI0W3SqFx/JV5gyuKqz1rcBvk74hyvfbz0cRxHqszqyxU4D3dmDRB4eS qgmmr1WxVWOeTvT8QEOx3TarUhaMsKELTIbLqA904k6GwhIQiPAhGeywokxwHnHCHdB2J JR1UBqFdrQvQsZvJI/jVARGd3dnvkkx8qrKJA4BAWStywm7BWpoMw9QoWfdnVKxund2l+ gOaiR2tby9ae8pfVyq867LHTjUhrAQ/+ccdlP6T3qhNusOQnZPomtshhOfb/ASjSyVg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796340721; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=oJJRqXQ7Gdc6Ta9X01M0xRcgHig87hhCiiqIVEyMMFg=; b=q7qDy3OdKBFS8dT6nv/AmaEhSt39t0b6m4+vfMmoiOE37hS1kHQMygFs6VQFKgpMYDCj 09ojBrNfHLd5Di5fE98RB05cInp0bM3HGT7mB/43uKla1YV8Eo9/25Gx8YgKWnyR29uBD l9vAp2I+5JRK72Pm88ACOD9dYcqNLTGNT8120/fa7v8qsHuBZpgCmPnlVySSEOrCWk3qU n2ow3XAzcENd2iSbznf8mpRM8OeGQipKxKQ8lB7ruWj6tkAbOMGDg3quHLP0mfH1Sw+0f YQpTbD9VN1M24bd6xetAV5QVtHR+fo5kfwm4creqTUV65nh7i9WBtUVh9ySCmNjUD+w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i8cR6dDk; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC742606A322 for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 23:32:01 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F6C61F0092B; Thu, 3 Dec 2026 23:32:00 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796340721; bh=oJJRqXQ7Gdc6Ta9X01M0xRcgHig87hhCiiqIVEyMMFg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=i8cR6dDkpp/Fz67UlhQGq8YFKSsW+UvZpP0nDCuS3/3SaOE2dzFsqgv28eo93xxD+ VNsNa119gHJqJJgabJLTVhb7/az+4f5xTB/xS4eZGry311WHcxJFkM5KRVVK4hdUqH tzBQZL/ARNrlPRFhgIhNqlA25EtoXRhoe5QpQBdicdl+oYhS2j132jGm0HD6eVyBWl igAExT4stBJnNLUACPCw3w7CvZ9x1hL4ugkQYaF7W9+QUNg6yl8O/uPvrREqfWNam9 vt0MAfDEcUw2Uwx7O2OHsIC0gfr2npHZR4VGoKUyRfdULOrVUGKizp4xL/TCWEybO9 lnDE2xZJ+8bCg== X-Cc: heiko@sntech.de, maxime.chevallier@bootlin.com, 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, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com X-In-Reply-To: <20261201082932.3199297-1-fuwh1120@163.com> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list