lkml.org 
[lkml]   [2023]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1] net:thunder_bgx:Fix resource leaks in device_for_each_child_node() loops
Date
The device_for_each_child_node() loop in
bgx_init_of_phy() function should have
fwnode_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 a317feb8d..dad32d36a 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
\
 
 \ /
  Last update: 2023-07-04 16:16    [W:0.026 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site