Thread (3 messages) flat view 3 messages, 3 authors, 5d ago
COOLING5d

[PATCH 1/2] net: thunder_bgx: fix fwnode leak in bgx_init_of_phy()

From: manushprajwal <hidden>
Date: 2026-08-23 11:13:17
Also in: linux-arm-kernel
Subsystem: arm/cavium thunder network driver, networking drivers, the rest · Maintainers: Sunil Goutham, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

If a child returned by device_for_each_child_node() is not backed by
a device_node, to_of_node() returns NULL and the loop is aborted with
a bare break, without releasing the reference on the current fwnode
that device_for_each_child_node() took. Call fwnode_handle_put()
before breaking out of the loop, mirroring the existing of_node_put()
call a few lines below for the "lmac == bgx->max_lmac" exit path.

Signed-off-by: manushprajwal <redacted>
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index b63039999..246eee327 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -1479,8 +1479,10 @@ static int bgx_init_of_phy(struct bgx *bgx)
 		 * cannot handle it, so exit the loop.
 		 */
 		node = to_of_node(fwn);
-		if (!node)
+		if (!node) {
+			fwnode_handle_put(fwn);
 			break;
+		}
 
 		of_get_mac_address(node, bgx->lmac[lmac].mac);
 
-- 
2.46.2.windows.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help