Article View: linux.kernel.netdev
Article #23815Re: [PATCH] net: ethernet: sunplus: spl2sw: fix OF node leak in spl2sw_probe()
From: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 08:04
Date: Sat, 28 Nov 2026 08:04
130 lines
12205 bytes
12205 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 2
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 fix is incomplete.
- [Low] The patch fixes a reference leak that dates back to the original
driver, but it has no Fixes: tag.
- [Low] The diffstat in the patch notes does not match the diff.
--
net: ethernet: sunplus: spl2sw: fix OF node leak in spl2sw_probe()
In spl2sw_probe(), the "ethernet-ports" node comes from
of_get_child_by_name(). This patch adds an of_node_put() for it after
the port setup loop, to fix a leaked reference on the probe path.
> spl2sw_probe() calls of_get_child_by_name() to obtain the
> "ethernet-ports" child node and uses it as the parent for
> spl2sw_get_eth_child_node() in a loop, but never releases
> the reference, leaking it on every probe (and on every
> goto error path).
>
> Drop the reference with of_node_put() once the node is no
> longer needed.
>
> Signed-off-by: Zhao Feng <zhaofeng2@cmss.chinamobile.com>
[Severity: Low]
Should this have a Fixes: tag? The of_get_child_by_name("ethernet-ports")
call in spl2sw_probe() arrived with the original driver:
Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
> ---
> Verified against current tree. Leak found by code inspection
> (OF reference-counting audit of spl2sw_probe()).
>
> net/ethernet/sunplus/spl2sw.c | 2 +--++
> 1 file changed, 2 insertions(+), 0 deletion(-)
[Severity: Low]
This isn't a bug, but the diffstat doesn't match the diff. The patch
changes drivers/net/ethernet/sunplus/spl2sw_driver.c, and
net/ethernet/sunplus/spl2sw.c does not exist. The bar also shows
deletions, but the diff has none.
Was this diffstat written by hand rather than generated by git
format-patch? With the error paths noted below, is the "Verified against
current tree" note accurate?
> diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c
> index b5ae950f6d5b0..ce1045813f9cc 100644
> --- a/drivers/net/ethernet/sunplus/spl2sw_driver.c
> +++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c
> @@ -476,6 +476,8 @@ static int spl2sw_probe(struct platform_device *pdev)
> spl2sw_mac_rx_mode_set(mac);
> }
>
> + of_node_put(eth_ports_np);
> +
[Severity: High]
The commit message says the reference leaks "on every goto error path".
Does this release cover those paths?
Only a normal exit from the port loop reaches this of_node_put(). Three
exits inside the loop jump straight to out_unregister_dev:
drivers/net/ethernet/sunplus/spl2sw_driver.c:spl2sw_probe() {
...
ret = spl2sw_nvmem_get_mac_address(&pdev->dev, port_np, mac_addr);
if (ret == -EPROBE_DEFER) {
goto out_unregister_dev;
...
ret = spl2sw_init_netdev(pdev, mac_addr, &ndev);
if (ret)
goto out_unregister_dev;
...
ret = spl2sw_mac_addr_add(mac);
if (ret)
goto out_unregister_dev;
...
out_unregister_dev:
for (i = 0; i < MAX_NETDEV_NUM; i++)
if (comm->ndev[i])
unregister_netdev(comm->ndev[i]);
out_free_mdio:
spl2sw_mdio_remove(comm);
out_clk_disable:
clk_disable_unprepare(comm->clk);
return ret;
}
None of these labels drop eth_ports_np. Doesn't the reference on the
ethernet-ports node still leak whenever one of these gotos is taken?
The -EPROBE_DEFER case happens routinely. of_nvmem_cell_get() returns
-EPROBE_DEFER until the nvmem provider binds. Each deferred probe retry
would then leak one more reference on the node.
Could this use an unwind label that drops eth_ports_np before falling
through to out_unregister_dev? Declaring eth_ports_np with
__free(device_node) would also work.
The next leaks are pre-existing and were not introduced by this patch:
- spl2sw_get_eth_child_node() returns early from inside
for_each_child_of_node(), and the port_np reference it returns is never
released.
- phy_np leaks on the error exits.
Would a respin be a good time to fix those as well?
> /* Find first valid net device. */
> for (i = 0; i < MAX_NETDEV_NUM; i++) {
> if (comm->ndev[i])
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127074228.268-1-zhaofeng2%40cmss.chinamobile.com
Technical Details
Message-ID:
<179585308901.3135.3807804002976380282@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373049-linux-kernel-netdev=dewy.ruReferences:
<20261127074228.268-1-zhaofeng2@cmss.chinamobile.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373049-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH] net: ethernet: sunplus: spl2sw: fix OF node leak in spl2sw_probe() Date: Sat, 28 Nov 2026 08:04:49 +0000 Organization: Usenet Network Message-ID: <179585308901.3135.3807804002976380282@kernel.org> References: <20261127074228.268-1-zhaofeng2@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="909601"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:0dDTu+3yDLbGw3j35rR5PGT3u9Q= sha256:IBQMyfgujOfVx9xtA8NtWH/EIGscXdc+q5L8j8POX+Y= sha1:OHEQeARFGB7WYQTU5JitF/HiTeM= sha256:PypGVLlZ3WV5Hw+pg3laOiVSmNvkulD3YDVAbTUggW0= 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 E5C53125F6F; Sat, 28 Nov 2026 11:05:15 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[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, URIBL_BLOCKED=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 iYU_BecKXoQg; Sat, 28 Nov 2026 11:05:08 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373049-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 D5F33125F71; Sat, 28 Nov 2026 11:04:55 +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 65B4523882; Sat, 28 Nov 2026 08:04:53 +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=1795853091; b=cNytswa7lupM0QLoFV+pWALLTOsJ6D/lhHhIwp78rvgf8/vum+IF4QnHMEijFrlsk3g9 UfjuE7cYqTg5uz4cQCoVCDlslFpsjpsZ6CaFsWF0MxVhsCZ4yzvbwksBZIyGNyo+KvMRB DIVuGZ8ESpfFk6PodAVmSDl5oYva0ZZtt02fuRGoOmwE+Kf1XgsGaAyj1GyvRCeKqqY4y 40pLutlUrsM/nq8qggSA6EQOwzmF5sQshls2UZz7Fio3d7rW7q0ROjukkCn/ICTkB/A/C PHmHO/qF9y0uUlHtvIPrSQAw1HxX0WReYahw0NY1maax9fbCxXIQnSD6GCepELypaqw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795853091; 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=MEmK62uLXuWw4WdQtZl8BjBNwRsMM/P7sRqpkRfqtuc=; b=2J4ihmwSfMmpaMo4n3OZLChIu+8P0M6niAT2PcSM6g//iLA9/2fjwQ2hkwLuIXJS1CXa kPJfO87RgG5lRQ5Thjue8F61m8kTz4xQHreM/t2dAhro4mX7Skl8lzTpm8eJISqRyQZqX 3edF1syao/ke05CWkur4lrj9XhpSO8e/dC/nd3Fp8uMS7ZA1y7MszQaq2ZuztyQWDx5Al KyLO3b4J4R6f/QSa5KZtSrBQSaIMX1UVWwxRoy1Qq244Q/bhBnNGpthQ70Ulul5/DaFEY QumtilVnHMeEsqWF8cPpHJRCZGDSdbfcOaOwYmwQImnmt39Z1Jebd06CjwUE9x+wHBQ== 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=ftYq+aB3; 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 0E085606A329; Sat, 28 Nov 2026 08:04:51 +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=ftYq+aB3 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=1795853090; b=5Je+e9Cs7NIXf/QHYLoEiWwF/iTMNkUSX8L6TxfQXR3BQe4/HwF77OBX0YoO4y/JRy+C Ft66niTaDE6WkycZSs5WYajYtKqUpv4XhWoICPT2AVa7YAKxSlxwL8s8kvqp2+Qonwr/T WqOf2gfkmZGSA+srXDbEvvjG4+y9VephYperVxRKCJzf7HBcvy7XNs3f3pukM3zpdI0Zl jVOi0N7uwf0MkGk129WIdcunGnHOdYbnOshrkoFa6PFx8edtrzbjOQBqOVHjgTDyW/1m7 1VMsF6wt3sth6RjPWgWPSxZicStgL3mGssiHAWwDKUm0IOqn6weqaBWlcgaco5hP0NA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795853090; 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=MEmK62uLXuWw4WdQtZl8BjBNwRsMM/P7sRqpkRfqtuc=; b=SxA3uxbxscM+1e7UTNSsptzhCQ2gcvEs4tNgVvp1GcJAwzlzfJORefaVclW+BAFJnpxM W82eefEDzlIutUuxA2YFZ4Ma7+/bGg0jhhBwuDbupMQmrfjYLR+9Zi3pvh9iX+//j4H7O r0gfC0ynGin5LA+3WHxQElVlVeF85jGoJMrXyltTltL2EU8dS8GvvP9g8qrp+/eWYHq2/ 1BzU3QtK+udnjn0PTBfgUMpsm0Lz7LxFuMwpnytfabYY75uYnE4U5Hk4/P5mTP/TK+OB/ iXSa17USU4JyFQ8VgaTPPQ82x+2MLojx2x8ZKLUUlipfbdti0Xr8Tb9xSroDC7scCrA== 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=ftYq+aB3; 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 2856A606A31C; Sat, 28 Nov 2026 08:04:49 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 752A61F00893; Sat, 28 Nov 2026 08:04:49 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795853089; bh=MEmK62uLXuWw4WdQtZl8BjBNwRsMM/P7sRqpkRfqtuc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ftYq+aB3NOJ2EeyX8dRMQVMIIMpcSorM4DO5VbjACov9P/d7USAeqEq8S+XeP8Cma qyEzIQCXFjh+ihegTlZZi3eE0bN8Ysqb3gnvLlMQDhQuRJh4XD7PyKALFF7YaN4bLl 5z8RvK9gH7sUXLw3dRwsBc4IrygVq2+/x4gf5E39nT7yK1ISSmXfA1RxQ3OKf4n7cG t4dRiQUYKGtsKROStjhUnptfiTdmNU5uWjSgo4mK0AbGKyHv87fbQoghXiPScQs94v MZ8DeMyqqJc3RctfkIcyryZbZx3KUJmdFNDT+Jw8CdZr5TAoeIBXKqcyPR/AcXnurq +xlZh/11UDSAQ== X-Cc: wells.lu@sunplus.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kuba@kernel.org X-In-Reply-To: <20261127074228.268-1-zhaofeng2@cmss.chinamobile.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