Article View: linux.kernel.netdev
Article #21719Re: [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: Put the EPHY clock and reset after the MAC
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 11:16
Date: Tue, 24 Nov 2026 11:16
93 lines
11612 bytes
11612 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit fixes a real use-after-free on the sun8i_dwmac_probe()
error path but has no Fixes: tag and no Cc: stable, so stable treesโฆ
--
net: stmmac: dwmac-sun8i: Put the EPHY clock and reset after the MAC
This commit moves the reset_control_put() and clk_put() calls for the
internal PHY so they run after stmmac_pltfr_remove(). Before, they ran
before it, both on the sun8i_dwmac_probe() mdio-mux error path and in
sun8i_dwmac_remove(). This fixes a use-after-free because
sun8i_dwmac_exit() still uses ephy_clk and rst_ephy to unpower the
internal PHY.
> net: stmmac: dwmac-sun8i: Put the EPHY clock and reset after the MAC
>
> sun8i_dwmac_exit() unpowers the internal PHY through ephy_clk and
> rst_ephy, but the probe error path and sun8i_dwmac_remove() put both
> before stmmac_pltfr_remove() calls it. If mdio_mux_init() fails after
> the scan of the internal bus has powered the PHY, this is a
> use-after-free.
>
> Put them after stmmac_pltfr_remove(). The explicit unpower in remove()
> is then redundant.
>
> Suggested-by: Chen-Yu Tsai <wens@kernel.org>
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
[Severity: Low]
Should this have a Fixes: tag, and perhaps Cc: stable? Without them, the
stable trees won't pick up the use-after-free fix automatically.
The ordering problem seems to come from commit 529254216773 ("net: stmmac:
dwmac-sun8i: Balance internal PHY resource references"). That commit added
the puts under the dwmac_mux label, and that error path then called
sun8i_dwmac_exit() explicitly.
Today, the same error path falls through to:
stmmac_pltfr_remove()->stmmac_dvr_remove()->sun8i_dwmac_exit()
->sun8i_dwmac_unpower_internal_phy()
When internal_phy_powered is true, that runs clk_disable_unprepare() and
reset_control_assert() on handles that have already been released.
The flag can be true here. mdio_mux_init() scans the internal bus first,
and mdio_mux_syscon_switch_fn()->sun8i_dwmac_power_internal_phy() sets it.
A later child bus can then fail with -EPROBE_DEFER, which is an ordinary
event.
Would something like this be appropriate?
Fixes: 529254216773 ("net: stmmac: dwmac-sun8i: Balance internal PHY resource references")
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 2ece7ba9dd73b..9fb398f7cf9ec 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -1236,7 +1236,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
> ret = sun8i_dwmac_register_mdio_mux(priv);
> if (ret) {
> dev_err(&pdev->dev, "Failed to register mux\n");
> - goto dwmac_mux;
> + goto dwmac_remove;
> }
> }
>
> @@ -1244,12 +1244,11 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
>
> return 0;
>
> -dwmac_mux:
> - reset_control_put(gmac->rst_ephy);
> - clk_put(gmac->ephy_clk);
> dwmac_remove:
> pm_runtime_put_noidle(&pdev->dev);
> stmmac_pltfr_remove(pdev);
> + reset_control_put(gmac->rst_ephy);
> + clk_put(gmac->ephy_clk);
> dwmac_syscon:
> sun8i_dwmac_unset_syscon(gmac);
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25%40gmail.com
Technical Details
Message-ID:
<179551897540.3135.862711203479532427@kernel.org>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370271-linux-kernel-netdev=dewy.ruReferences:
<20261120-sun8i-emac-mux-uaf-v4-1-57eba8915f25@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370271-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: Put the EPHY clock and reset after the MAC Date: Tue, 24 Nov 2026 11:16:15 +0000 Organization: Usenet Network Message-ID: <179551897540.3135.862711203479532427@kernel.org> References: <20261120-sun8i-emac-mux-uaf-v4-1-57eba8915f25@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4121624"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:X+5Y75irELVyRFhoc3L8XZnFXJg= sha256:UV/cy0MTt+WAGngqW/nLgGbcxO3FG+rtVpEnb+JJ6ZA= sha1:urnfyy/re+/h84uol7Fa7enLs4c= sha256:dtDvTZHoqXzlCc8YldWwMGRToaBDZQ2AZvGJhjMCl7s= 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 73B46125DFC; Tue, 24 Nov 2026 14:16:42 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 3SgrtaaCKnjx; Tue, 24 Nov 2026 14:16:38 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-370271-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 D4A8D125E02; Tue, 24 Nov 2026 14:16:28 +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 53C3831D11; Tue, 24 Nov 2026 11:16:23 +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=1795518983; b=IYHPpBvOmMSgh/G222oBI8nwOi662/OExcwVWW8Grilc852MVrOW0eap+2QtQ25UF7Fn cpBFXDwT1icEBU5swGhEbxtsrUAdvNT+QgHfwDdaBg7rahHvJpDBPXy/TbJ0Dn4QsYfPE mfco6sHE9F3RKV5/o8HKBOEGoYdmU9SPzyR9nvwr4q/PbfkaVqUXoEohIpCEMsvbzxM8t EHD3pLW9tTT/IzFLSf/CbPpnwe3YMIxTemmzO/9WfL0f48fQsI2D0cSFQFcneJWauAgT/ 4rtYRQwmVN4GoIQ0WGzIyTpDgtwUYbl93UKpI27sj1DXGLwsZ8a4zJMbAkZ5n17h4Eg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795518983; 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=tybZ8A9gQEPaCmNc6ZBx7xtz6zHhGLsPWUWzuEyVLfQ=; b=SZZ1nsr5zrtuSXqxmUrYaloqToYvTdgS+NjmcY5Qarxd0Zy0Umr/yQ6HkUJojiS1tzNC BzMKgayB/uIL76cnB3clQIv8c8PY/Q3/AOfTYpNCHlJ1O/P1D+3Xrm3YCfJ8yNx5uxttu BMe3692Zuv5gBr1dVkosNS/i1D5oJ4zh9DEl5AG3aBNrMhnK/I0kUTrFEwiKOe8S0Vo86 k7nuodIyYaRLcscyFVOMLTpcuATo1NPvgLaz3PtO2aC81o8o4FUWE8qYo9p1XrGnGCqql aTvCagpXjezhaDu7OVxVeLGtTXQpKdHP95tWztb76lo3haQ70Feg3dM3gG/IZ1boQoQ== 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=QWX15aP3; 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 2B4B3606A33C; Tue, 24 Nov 2026 11:16:23 +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=QWX15aP3 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=1795518977; b=2MZPtFwxmyVqktBIfWbF8UnuXlELHIFnaw3Tst9NCK00LDNbA7s4PjQGkl66IfRcBcpy 58OyLecBLp89a4e5da7eazDQnTbPYyjHUC6KDsjnmyN/ym6Vd0jyEGA4Azj8kdzrlOPQ6 hphTOrSKjkBFoa6Ip1Nk96zo5BiN5/9iuzVOZYUWE05DFer3siWaDE/tCgDfkI25c8RoL EH+17IMs/Vcerjt5a80w+7gtjCBBQB2Jqg54fifa6r1SQcUgIwvFy5bmPbosUWkBYHeiQ S7h6gVVl+5gmC2colKUdjxAw402Z+QB3MH6Go4sIcT1K9M6WaGwD7uts5jI0szx9wAQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795518977; 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=tybZ8A9gQEPaCmNc6ZBx7xtz6zHhGLsPWUWzuEyVLfQ=; b=23aYU1YxB5v/N7Wfie4MJeJzRoDrxp1dHTj5hyhzf6n7FhXRnvDIc8HQP436eBRXfSTy YcLssJxXov++Q/j3ZeVFBisqCGmYAgxBtAfiDSdUP+I7kIqAY/XLCbvOhh4wpirlY40+r 2Qlfb0fft7XjLro5ruQ1yWtzYZDoH8fs356hXFsQbF5LlIZQtWuVTBp2TFR4E3RZVfrbo Pr8a4GDwaAL3r7magnwLMKNexkl8LnF5AWplI66sl2N71dwX9W+8FPfEo0tJBGGYj9erN LBT1WMlm7E0qG1Hrux34cBpXvZwH4l3nqZ89Sh2VP25tItmjNyeELPlxVxZjMvCdnfg== 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=QWX15aP3; 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 49504606A31E; Tue, 24 Nov 2026 11:16:16 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D45611F000C0; Tue, 24 Nov 2026 11:16:15 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795518976; bh=tybZ8A9gQEPaCmNc6ZBx7xtz6zHhGLsPWUWzuEyVLfQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=QWX15aP3PT81dY6/DPQL3gVieVvQ6oTnTRBjI50dADq62vH9PBHJZ1bw/kPPeDTe6 2WTm2ZTLjFV5Wq0WgxvA68MI3/eT3T0jzYH2ohpsw0qvCZ480OTVKSj4/8Nbi4OIVp J7Y+K3TgTTF0fUcUQ8fI5AOdFwAGYc6f01YD4dqv/LU4qDqlUoqxptNgFGlH6x3xBI xShKmi0u3MFPxWBC6YhhZvTqcsuxXxGuBFDfovKufkrMpgHd+oijxwiKn4UW0+peMb Wpz0+WglLKkwG4AKdGBR1mYuT2bm1UJ2vkGYT3g9RAylLi5lbcmBAHCoAv1gUxk2B1 BG8xoxVz6Qa8g== X-Cc: 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, wens@kernel.org, jernej.skrabec@gmail.com, samuel@sholland.org, p.zabel@pengutronix.de, linux@armlinux.org.uk, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-stm32@st-md-mailman.stormreply.com, linux-kernel@vger.kernel.org X-In-Reply-To: <20261120-sun8i-emac-mux-uaf-v4-1-57eba8915f25@gmail.com> X-sashiko-severity: Low 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