🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10230

[PATCH] net: ethernet: sunplus: spl2sw: release the port node in probe

#10230
From: Wentao Liang
Date: Tue, 03 Nov 2026 10:28
52 lines
9831 bytes
spl2sw_get_eth_child_node() returns a device node reference obtained
from for_each_child_of_node(), so the caller must drop it with
of_node_put(). spl2sw_probe() never does, leaking one reference per
port on both the success and the error paths.

Drop the reference once the node is no longer needed and on the early
continue paths.

Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/ethernet/sunplus/spl2sw_driver.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c
index 5e0e4c9ecbb0..551d36ea0579 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_driver.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c
@@ -427,6 +427,7 @@ static int spl2sw_probe(struct platform_device *pdev)
 		if (of_get_phy_mode(port_np, &phy_mode)) {
 			dev_err(&pdev->dev, "Failed to get phy-mode property of port@%d!\n",
 				i);
+			of_node_put(port_np);
 			continue;
 		}
 
@@ -435,17 +436,20 @@ static int spl2sw_probe(struct platform_device *pdev)
 		if (!phy_np) {
 			dev_err(&pdev->dev, "Failed to get phy-handle property of port@%d!\n",
 				i);
+			of_node_put(port_np);
 			continue;
 		}
 
 		/* Get mac-address from nvmem. */
 		ret = spl2sw_nvmem_get_mac_address(&pdev->dev, port_np, mac_addr);
 		if (ret == -EPROBE_DEFER) {
+			of_node_put(port_np);
 			goto out_unregister_dev;
 		} else if (ret) {
 			dev_info(&pdev->dev, "Generate a random mac address!\n");
 			eth_random_addr(mac_addr);
 		}
+		of_node_put(port_np);
 
 		/* Initialize the net device. */
 		ret = spl2sw_init_netdev(pdev, mac_addr, &ndev);
-- 
2.34.1
Technical Details
Message-ID: <20261103102852.1340500-1-vulab@iscas.ac.cn>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355426-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355426-linux-kernel-netdev=dewy.ru
From: vulab@iscas.ac.cn (Wentao Liang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH] net: ethernet: sunplus: spl2sw: release the port node in probe
Date: Tue,  3 Nov 2026 10:28:52 +0000
Organization: Usenet Network
Message-ID: <20261103102852.1340500-1-vulab@iscas.ac.cn>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3146537"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Jr8M9JiTeYn17aJ/UHw5V6eQFeg= sha256:ysYtyLRZD3GKma4CDpXZy5jIrxQexiPgepx3WKiALPA=
	sha1:Bg+5DL2vAZO4KfKXETnZhozk/L0= sha256:nBba3Je19d5d9sGzX8Vzt7QUT1vpxVGcvD+1sBnZN8c=
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 24D18112802; Tue,  3 Nov 2026 13:56:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 0.607
X-Spam-Status: No, score=0.607 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SBL_CSS=3.558,
	SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no
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 kvnS6dMkcHDL;
	Tue,  3 Nov 2026 13:56:52 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-355426-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=iscas.ac.cn
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A07C91127FE; Tue,  3 Nov 2026 13:56:48 +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 57437826FB; Tue,  3 Nov 2026 10:37:26 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1793701735;
	b=4wsEDMnQUvRJ1L2n+lJbvfbJfxLPg6E4ryukajMdfIZ0E5SXqvB9fNOF4ZvpZcwJf08A
	 sMLzA8Jm6nAiNEuIdUcyoo+sVFOHUF9yL7K2rNzZgVz+CRFxEavAaQ5rx5vrhHf+BcZPq
	 FVGsktetLb+jo0p+E4W1siqPwL73XnKCyft4DOytPzuY1CZM7FZdl3FeaFC19hluKWVYg
	 DZ7X018vVj5lK3k8+reRy7OflScJaiHxCEPRcBM+N07kp+SgqretNqoDYCbJ5slaJIAzE
	 DEJUgK8UimGtoOQJiEWhFaw8/jNzfOk1rYFV1a9vtgF7EsNji3ksY+0a1M7Qhf0HBBw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793701735;
	h=X-Original-To:Received:DMARC-Filter:Received:From:To:Cc:Subject:Date:
	 Message-Id:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam:
	 X-CM-SenderInfo;
	bh=1nWpelF9/VGZh/vb7Tz46GHWSc2AwSVyy7M1a5xC1/I=;
	b=l5CABqVHvIUD7GNF/0tQNSdYvP48XZIqX4oNE4K1FIO9MvZcGPV2JcqTtZRiZR1wZmRG
	 fGQhGKqG9x0Y//ZW1c13uFwmEdF05/CyQYBosis4WU529piIBgf/5c9bs8uSb71JH71hr
	 UJ8k0HOOOakkBsh9dHzsq5MY4sNSVbdxhVUokqBL4l0TGqlbPaQaeLpGyT2HUDvX730oc
	 +aEZUnOLn8jI3MJAt9kBguCFCTU9eqPIDSvcaPw4dmzLoeulsLj28OpkkTVV/etZjBpxk
	 qPsBHeMP27cclEHzeI4Z//EVYwUMuhvdtRumpkcBVfKGzLK1rivPeqCVLJbCTCVUKSQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=none header.from=iscas.ac.cn;
	spf=pass smtp.mailfrom=iscas.ac.cn;
	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 7E1C56074A19;
	Tue,  3 Nov 2026 10:28:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=159.226.251.81
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793701729;
	b=dnK2lztzHk1/EeuyfqoxfR2RnZK8BY5sqAC2diCm8x1qZsQkaYHpYymEt3+PWY2u2Ad0
	 UZJgj/nL2XqJnuRJrzRBE+nAZhY85ZEGNu/cOkBjxBk1Ft/kHDuA9fANL8Mx9ahDVYTXS
	 duTBV2qFA2VzbfGkgrr/LIjImwudURu8LGzZtTY2BMyMVh4Gd4Y1GReUTXxg4LHzxomqL
	 n0lFCd8+onGWrfI7NL3oSZIyZbLkoP4SOaTcv51Pzi3fG4kZFAYh8DcJqHKK5cYMSIWTJ
	 UllxQCf5N+Sje6oGwyW0YzUdKyd+9AiWaQvm13sJo7WO8WttSyknfLUc/QebQJqcohw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793701729;
	h=DMARC-Filter:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding:X-CM-TRANSID:
	 X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo;
	bh=1nWpelF9/VGZh/vb7Tz46GHWSc2AwSVyy7M1a5xC1/I=;
	b=vYRab8On/bOch9V/JQwdbHZrzT90Vtz9rOX6kkkc5N2qDP/infslGNhPcgpX2q9IL2I1
	 SrZmzSaatPqnr6Vs8uYBtuxWJnjm+9a0f2IslFvaMnA/bBVK8EfEtJyN/dhtMfOSt1ud0
	 /D8cXp7q5MPewGdSaLcoT4O2jxh4JXZ2ge2sF2oKqqY4qYoRH7CELORIxIjWckxzU6zfb
	 gPYmxbVR1hIqy8KKwQdKv96O+Rpj/7dMf/td9X/rYm13alAImF9vLo2fj5qZLK6pnenJ3
	 e88ieOXbPTaOrck37mV78rh4mIKXpnzbPVbqb/xg0Q207967714C8MMkCOb/KUnppWA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=iscas.ac.cn;
	spf=pass smtp.mailfrom=iscas.ac.cn;
	arc=none smtp.remote-ip=159.226.251.81
X-Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81])
	(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 5AD8D6071534;
	Tue,  3 Nov 2026 10:28:47 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5AD8D6071534
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn
X-Received: from dfae2b116770.home.arpa (unknown [36.110.52.2])
	by APP-03 (Coremail) with SMTP id rQCowADn9ZZbt+lqeak7AA--.2751S2;
	Tue, 03 Nov 2026 18:28:43 +0800 (CST)
X-Cc: netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.34.1
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-CM-TRANSID: rQCowADn9ZZbt+lqeak7AA--.2751S2
X-Coremail-Antispam: 1UD129KBjvJXoW7uFyUGFy7uw4rKFykur17KFg_yoW8Cr18pa
	yUGayY9ryqyF4xAa4xtw18AFyYk3WDKrWF9a1Iyw4ru390yr17Ar4DWFyjvrWrCFWkKF45
	tr1UAFykZFs8A3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2
	9KBjDU0xBIdaVrnRJUUUkK14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0
	rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2A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