Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH] staging: octeon: release the port device node in cvm_oct_probe
@ 2026-11-04  2:14 Wentao Liang
  2026-11-04  7:12 ` Krzysztof Kozlowski
  2026-11-04  7:45 ` Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Wentao Liang @ 2026-11-04  2:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging

cvm_oct_probe() looks up the device node of every port with
cvm_oct_node_for_port(), which walks the children with
for_each_child_of_node() and therefore returns the node with an
incremented reference count.  The reference is stored in
priv->of_node and used for the lifetime of the net_device, but it is
never dropped: both probe error paths free the net_device without
releasing the node, and cvm_oct_remove_device() does the same on
unbind.  Each failed or torn down port therefore keeps its device node
referenced forever.

Add the missing of_node_put() in the two probe error paths and in
cvm_oct_remove_device(), which also covers the error cleanup done after
the ports have been registered.  of_node_put() accepts the NULL node of
the POW device.

Fixes: 422d97b8b05e ("Revert "staging: octeon: delete driver"")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/staging/octeon/ethernet.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 42ec4b8324a8..bba46127ef9d 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -114,6 +114,7 @@ static void cvm_oct_remove_device(int port)
 
 		cvm_oct_tx_shutdown_dev(dev);
 		unregister_netdev(dev);
+		of_node_put(priv->of_node);
 		free_netdev(dev);
 		cvm_oct_device[port] = NULL;
 	}
@@ -919,10 +920,12 @@ static int cvm_oct_probe(struct platform_device *pdev)
 			}
 
 			if (!dev->netdev_ops) {
+				of_node_put(priv->of_node);
 				free_netdev(dev);
 			} else if (register_netdev(dev) < 0) {
 				netdev_err(dev, "Failed to register ethernet device for interface %d, port %d\n",
 					   interface, priv->port);
+				of_node_put(priv->of_node);
 				free_netdev(dev);
 			} else {
 				cvm_oct_device[priv->port] = dev;
-- 
2.34.1


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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:14 [PATCH] staging: octeon: release the port device node in cvm_oct_probe Wentao Liang
2026-11-04  7:12 ` Krzysztof Kozlowski
2026-11-04  7:45 ` Dan Carpenter
2026-11-04  8:34   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox