* [PATCH] net: ethernet: sunplus: spl2sw: fix OF node leak in spl2sw_probe()
@ 2026-11-27 7:42 zhaofeng2
2026-11-27 7:49 ` netdev-bot+sinfo
2026-11-28 8:04 ` netdev-bot+sashiko
0 siblings, 2 replies; 3+ messages in thread
From: zhaofeng2 @ 2026-11-27 7:42 UTC (permalink / raw)
To: Wells Lu; +Cc: Zhao Feng, netdev, linux-kernel
From: Zhao Feng <zhaofeng2@cmss.chinamobile.com>
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>
---
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(-)
--- a/drivers/net/ethernet/sunplus/spl2sw_driver.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c
@@ -471,6 +471,8 @@
spl2sw_mac_rx_mode_set(mac);
}
+ of_node_put(eth_ports_np);
+
/* Find first valid net device. */
for (i = 0; i < MAX_NETDEV_NUM; i++) {
if (comm->ndev[i])
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: ethernet: sunplus: spl2sw: fix OF node leak in spl2sw_probe()
2026-11-27 7:42 [PATCH] net: ethernet: sunplus: spl2sw: fix OF node leak in spl2sw_probe() zhaofeng2
@ 2026-11-27 7:49 ` netdev-bot+sinfo
2026-11-28 8:04 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-11-27 7:49 UTC (permalink / raw)
To: zhaofeng2; +Cc: Wells Lu, netdev, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: ethernet: sunplus: spl2sw: fix OF node leak in spl2sw_probe()
2026-11-27 7:42 [PATCH] net: ethernet: sunplus: spl2sw: fix OF node leak in spl2sw_probe() zhaofeng2
2026-11-27 7:49 ` netdev-bot+sinfo
@ 2026-11-28 8:04 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-11-28 8:04 UTC (permalink / raw)
To: zhaofeng2; +Cc: wells.lu, netdev, linux-kernel, kuba
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-28 8:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 7:42 [PATCH] net: ethernet: sunplus: spl2sw: fix OF node leak in spl2sw_probe() zhaofeng2
2026-11-27 7:49 ` netdev-bot+sinfo
2026-11-28 8:04 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®