public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] net:thunderx:Fix resource leaks in device_for_each_child_node() loops
@ 2023-07-05 14:34 Wang Ming
  2023-07-05 19:10 ` Leon Romanovsky
  2023-07-05 19:29 ` Benjamin Poirier
  0 siblings, 2 replies; 3+ messages in thread
From: Wang Ming @ 2023-07-05 14:34 UTC (permalink / raw)
  To: Sunil Goutham, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-arm-kernel, netdev, linux-kernel
  Cc: opensource.kernel, Wang Ming

The device_for_each_child_node() loop in
bgx_init_of_phy() function should have
wnode_handle_put() before break
which could avoid resource leaks.
This patch could fix this bug.

Signed-off-by: Wang Ming <machel@vivo.com>
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index a317feb8decb..dad32d36a015 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -1478,8 +1478,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);
 
@@ -1503,6 +1505,7 @@ static int bgx_init_of_phy(struct bgx *bgx)
 		lmac++;
 		if (lmac == bgx->max_lmac) {
 			of_node_put(node);
+			fwnode_handle_put(fwn);
 			break;
 		}
 	}
-- 
2.25.1


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

end of thread, other threads:[~2023-07-05 19:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-05 14:34 [PATCH net v2] net:thunderx:Fix resource leaks in device_for_each_child_node() loops Wang Ming
2023-07-05 19:10 ` Leon Romanovsky
2023-07-05 19:29 ` Benjamin Poirier

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