From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE9BF606A322 for ; Thu, 3 Dec 2026 23:32:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=xJbDIxEN; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i8cR6dDk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=oJJRqXQ7Gdc6Ta9X01M0xRcgHig87hhCiiqIVEyMMFg=; b=xJbDIxENSqa242BqGkh4H1bl+x mXnA/QrjO2YYURZiTjPvP0XV5deHx3J+tVDcVhWlQVg02OYPfBvdcmyV3TkRroiGGpJM4Xj3jB+Jb h/inFHuNXe9ph8FReUWVeu5k+0WJodmn1O05y0/EXagZGoE63cD8xKH7w4xnYGn915ButOorZ1gKO ujNsAW2gmNPZ9KiVkMdZweBRgLNzQIuhZQGEdpwUJAdxTpDZE+LQ6pKmINdkggNcl3fvqJxq50L/5 ImKWZ9t9LqqGyIoabII/hGWg2mLYavSPM/GG2n0OisUAHXOhQXJoG/ELsJcnaH+XBYqy+hdE5d8Q2 TM7DmbcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZGHT-0000000GBPF-2Ub8; Thu, 03 Dec 2026 23:32:03 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZGHS-0000000GBOu-0RGf; Thu, 03 Dec 2026 23:32:02 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 800846011A; Thu, 3 Dec 2026 23:32:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F6C61F0092B; Thu, 3 Dec 2026 23:32:00 +0000 (UTC) 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== Subject: Re: [PATCH net] net: stmmac: rk: Fix clock reference leak on probe failure From: netdev-bot+sashiko@kernel.org To: fuwh1120@163.com 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 Date: Thu, 03 Dec 2026 23:31:59 +0000 Message-ID: <179634071959.3146.8780794952618737741@kernel.org> In-Reply-To: <20261201082932.3199297-1-fuwh1120@163.com> References: <20261201082932.3199297-1-fuwh1120@163.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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