mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: ethernet: sunplus: spl2sw: release the port node in probe
@ 2026-11-03 10:28 Wentao Liang
  2026-11-03 10:33 ` netdev-bot+sinfo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wentao Liang @ 2026-11-03 10:28 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Wentao Liang, stable

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-03 11:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 10:28 [PATCH] net: ethernet: sunplus: spl2sw: release the port node in probe Wentao Liang
2026-11-03 10:33 ` netdev-bot+sinfo
2026-11-03 10:40 ` Krzysztof Kozlowski
2026-11-03 11:11 ` Krzysztof Kozlowski

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®