[PATCH] net: ethernet: sunplus: Fix port node leak in spl2sw_probe()
From: Wentao Liang
Date: Thu Sep 17 2026 - 07:53:54 EST
spl2sw_get_eth_child_node() returns a child node with a reference held,
but spl2sw_probe() never releases it: the node is leaked on the
"failed to get phy-mode" and "failed to get phy-handle" continue paths,
on the out_unregister_dev error paths and when the loop ends. Declare
the node inside the loop with __free(device_node) so the reference is
released on every iteration exit.
Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/net/ethernet/sunplus/spl2sw_driver.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c
index fdc9c3196738..c124e5ef3588 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_driver.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c
@@ -320,7 +320,6 @@ static struct device_node *spl2sw_get_eth_child_node(struct device_node *ether_n
static int spl2sw_probe(struct platform_device *pdev)
{
struct device_node *eth_ports_np __free(device_node) = NULL;
- struct device_node *port_np;
struct spl2sw_common *comm;
struct device_node *phy_np;
phy_interface_t phy_mode;
@@ -418,6 +417,8 @@ static int spl2sw_probe(struct platform_device *pdev)
}
for (i = 0; i < MAX_NETDEV_NUM; i++) {
+ struct device_node *port_np __free(device_node) = NULL;
+
/* Get port@i of node ethernet-ports. */
port_np = spl2sw_get_eth_child_node(eth_ports_np, i);
if (!port_np)
--
2.34.1