🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19770

[PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: Put the EPHY clock and reset after the MAC

#19770
From: Arun Iyengar via B4 Relay
Date: Fri, 20 Nov 2026 10:45
67 lines
12604 bytes
From: Arun Iyengar <aiyengar1990@gmail.com>

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>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 2ece7ba9dd73..9fb398f7cf9e 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);
 
@@ -1262,14 +1261,12 @@ static void sun8i_dwmac_remove(struct platform_device *pdev)
 	struct stmmac_priv *priv = netdev_priv(ndev);
 	struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
 
-	if (gmac->variant->soc_has_internal_phy) {
+	if (gmac->variant->soc_has_internal_phy)
 		mdio_mux_uninit(gmac->mux_handle);
-		sun8i_dwmac_unpower_internal_phy(gmac);
-		reset_control_put(gmac->rst_ephy);
-		clk_put(gmac->ephy_clk);
-	}
 
 	stmmac_pltfr_remove(pdev);
+	reset_control_put(gmac->rst_ephy);
+	clk_put(gmac->ephy_clk);
 	sun8i_dwmac_unset_syscon(gmac);
 }
 

-- 
2.55.0
Technical Details
Message-ID: <20261120-sun8i-emac-mux-uaf-v4-1-57eba8915f25@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367876-linux-kernel-netdev=dewy.ru
References: <20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367876-linux-kernel-netdev=dewy.ru
From: devnull+aiyengar1990.gmail.com@kernel.org (Arun Iyengar via B4 Relay)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: Put the EPHY
 clock and reset after the MAC
Date: Fri, 20 Nov 2026 10:45:32 +0000
Organization: Usenet Network
Message-ID: <20261120-sun8i-emac-mux-uaf-v4-1-57eba8915f25@gmail.com>
References: <20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="3137271"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3wBfZicxt7EEJp3w6eZAM8YZkVQ= sha256:/Pd2xyZBuAu+zM0I24kEutL9wxWvkBfogeiuC1vSaGY=
	sha1:qhXLqVsrSu8kjkgVCUf7cn2f8ME= sha256:CVS3lh4oaHNj/gJYaSmNquHryuSbbAB191uxYcOLk4I=
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 E9D7C11596A; Fri, 20 Nov 2026 13:46:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.051
X-Spam-Status: No, score=-2.051 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, 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, FREEMAIL_REPLYTO_END_DIGIT=0.25,
	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 XCjYHh3u0tR3;
	Fri, 20 Nov 2026 13:46:25 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-367876-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id E25EE115966; Fri, 20 Nov 2026 13:46:16 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 209FF47BE5; Fri, 20 Nov 2026 10:46:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1795171549;
	b=fc1nwLHdTIgRePCMjcPiVnSxMx5U17AxkiV2ZTfzleNG6v1EaLrz38I5WpdvuHLdoRAX
	 j4jdPtMEuf8KBUuORJLuzl6oCWXJf9yzUanv5ok4y/GKeIYxKUBMfx+mwHU+HO10Sql50
	 RfvBFA9HicxzgNdLSkrcYMwPpN/AKvFhrPkSxN40beYoLW16ZK2AqerzjsCMuttay24IK
	 Nqp26lfvRZS6r65IVQsqvwZbUCjvJAU8E7Q9KEQD4g3jA7v8dwXJTWY7fMDgkbgC8Squ2
	 Nwq01xDh1RwhD3PdIF3peG0o3upWzP4TNmxns+3KXLgsAVXjVlSMxp5/gKWjFx2WFJA==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795171549;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date:
	 Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=ULv9Bdwa1mzjUCCyb50Jfy/iR+5Oeq3ji6ZCzv6E3po=;
	b=pmdY8EEioyK67swjeBgANqUy2jSJctfw1jaYD0nkEfWnhgAfaSUGiLSIMTlww8Cu/W1f
	 EKgN/8ViK2hPB9mRh3hRfhYSUe8sqW8LdkRkVZ27j9OA2n3dy5HAt4hx8RBSwhFNmg9g+
	 qYfpE4e0bz+EAXZd7NLA1GGvg+pd586XM6KZBWJT2bDaTWkaWqx+1FogGaPfg+WTAxlh+
	 +BM/5LF265sqCsYU09adbfFLDDDtJwqjyxJuQmR+rN94CYiTI4gOn+zC3ITKrNivTm+HO
	 3RE7WQOohAT9z9JGKb00drkGH4JaXC1iIJBMvi5gjJrAgtKQwVo198QbWNkeygB4hZg==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="JDK8l/2I";
	arc=fail 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 42E25606A335;
	Fri, 20 Nov 2026 10:45:49 +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=JDK8l/2I
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795171543;
	b=nh/pcNI+YIKqOCTMbH/95REgn5HP6xFylOFE6TRo+lcYxSwAbBctmt8zIr8dF4uTNHmT
	 BLV6Yk6zVBd9PzGcjdBcmH3LG1kFiGAsOVXGdYaoPT9JLBW+dO0Uxe9jqgB7AqAWumSCe
	 t44bsPMIgBeR7tYMw8tbBV93QJW8cWfTAYpyZ58Y6pPa0F298kykoGqNxEjL9pTxcDXco
	 wbjrOEj7FAb97S2gWTRqHBwA6zMiaqfA7HBADGN4sh681UAuQqa08ZruzCXr3hr1dCtqm
	 Xg7R7Z2lZqdexTyXi/oBtDX9k2g4xrOQX0b2n1Xfw1N7IP9a7rnkPuNWsX/nPDDvAqQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795171543;
	h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version:
	 Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=ULv9Bdwa1mzjUCCyb50Jfy/iR+5Oeq3ji6ZCzv6E3po=;
	b=vqx43eVajseByQhA44ToN7/VJdjzkyONhlEx7FPmLyLW2Lj3qJoEIFpcZFFHyR6Y2KhW
	 LPYHkKL7yu7a51v2giitDtuL7fxmFjwqzhItn31cZfpXoeNKezFeEjzavwQ+/ErFqGg9C
	 b1QD7Hqk/cD/bm9BBLu7eEaLTZADnoS7+TQbc3lThFLlJZykK0WrkOK9I/YHYlBxcCdXG
	 QJK45icycXOWiRzazVtlmDEApFWLu9aXvAr+yZtaCYQD1VuCa6/FuUfDfSAvWe0cOeyWx
	 0M5TB9g4fY2KqHB321TETTa3cM6HSYBzERCVv5T1vTCHoKqHYZjogcAxGyurxEmKiQw==
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="JDK8l/2I";
	arc=pass header.oldest-pass=0 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 5FB2B606A33D;
	Fri, 20 Nov 2026 10:45:43 +0000 (UTC)
X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77
X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none;
	t=1795171542;
	b=dKbHhZ5Y7PcP22YOo3dHPjyO6pFHhV9KNC1wTNidLmVyimy0BB99vPtJuh5tYRbPblYV
	 o5tHyneF6qVAZ5ZbOYLNJEM42pYBxz7TuKuAkcdqMvZ//gdv4E57qOcM5VOvndyIWoTJT
	 UGGx5aSY6SwdT5OfNj1SfGESpH7ZrCRcxCdoBdJBm3GNp6Yo+ZI4Vco2yZ6ED6W7ROHBu
	 ji/ClNlpdC0qb7c0iOi+cSnEFHlqN8KOg16oAEkY4EckTqtLzzGFzuQHIGOusupjgM1sD
	 UtvcDE59EgFUVbqgVr/G4TvCBEg/CQWlRTHC0x3vH3ZmkUcyE0Gw7/unJbIk919M5ig==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
	c=relaxed/relaxed; t=1795171542;
	h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type:
	 Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=ULv9Bdwa1mzjUCCyb50Jfy/iR+5Oeq3ji6ZCzv6E3po=;
	b=DryIxU6djca4XCGrI7Xy+YsKoXkD6Y/0bfLTQiX/cy5neAcIxswALWKpGEcTxdWmZlws
	 5m633KuH2Od/FFbaYcHFFodaVbcZhSz+uYRfpzVyuzOXFfl7yP0jdO46ooUgD0hzWBs5q
	 PPywdPpIHUi0zZtWXPsud5mTWojmv5XMDZI0AbkTCKytT/uK6KJIH8NnElsgdD0Zpecpk
	 y3Aay5ijvcAYanqnqH4KqeMs4UYHJEgJR7ApqjuhFfIJBJ6u0LPgdxm9XGtIeyxcKLG8W
	 O0Hfrj7Sdyv+aAFovvhrZLxrdsKTdEUcfv9ytI/MIrFh+p669FtQhcC/6PjuLj6NKPQ==
X-ARC-Authentication-Results: i=1; smtp.kernel.org; 
	arc=none smtp.remote-ip=100.80.115.77
X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77])
	(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.kernel.org (Postfix) with ESMTPS id 1EBE01F000D0;
	Fri, 20 Nov 2026 10:45:33 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795171542;
	bh=ULv9Bdwa1mzjUCCyb50Jfy/iR+5Oeq3ji6ZCzv6E3po=;
	h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To;
	b=JDK8l/2I1yOVrldLOFPwF0zm0NFHXwviqT9VVbtv8xT6pUCOQM3tf0EHTUbILC5Ay
	 TPHuEtZwC5+v+P9piVpeuTQ14XjL93jWCcbZYfeMZ5/FZCHwGORiMO6aCt2RC0OK+v
	 GG3YTXzg9flY4fw6+K1UAzD1tnUwUKUyWI4zMQCy7llGH7llcPw9/IoN1DDJA8DyMA
	 ZpOnJ8fl6Wi8KthVL/16Q10o8aI3VDD1TORIpe3zL17ZUkX6tJTtcEvBEUkLcoBeaG
	 rliJYC07ER58S8Fy5STyiOJhj5d1LfiL1XWscZX4tJXsHMfbXZ+175/emeaPsV+XvO
	 miixZzsxcOMRg==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
	by lkml.kernel.org (Postfix) with ESMTP id 9FA94497D5;
	Fri, 20 Nov 2026 10:45:32 +0000 (UTC)
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
X-In-Reply-To: <20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25@gmail.com>
X-Cc: 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, Arun Iyengar <aiyengar1990@gmail.com>
X-Mailer: b4 0.15.2
X-Developer-Signature: v=1; a=ed25519-sha256; t=1795171532; l=2122;
 i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id;
 bh=zeDU/ie5mpEDPgDE4ZGiqAqgOX9E3SDKKC5wYWtaBU0=;
 b=t/igZe+xTX/0i5PLRfuaa1Gv+fjIDiunNi9b8S5A+ogJpuhxE/sI+198+B+rfmqwhYg382Lpz
 opxtf4+8pQwC1U4RUjk6F22wyRVooUvNNchEEitqd61roewZ0fdpDIE
X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519;
 pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0=
X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with
 auth_id=1480
X-Original-From: Arun Iyengar <aiyengar1990@gmail.com>
X-Reply-To: aiyengar1990@gmail.com