[PATCH] net: thunder_bgx: add a missing of_node_put

Rosen Penev posted 1 patch 1 month ago
.../net/ethernet/cavium/thunder/thunder_bgx.c  | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
[PATCH] net: thunder_bgx: add a missing of_node_put
Posted by Rosen Penev 1 month ago
phy_np needs to get freed, just like the other child nodes.

Fixes: 5fc7cf179449 ("net: thunderx: Cleanup PHY probing code.")
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 .../net/ethernet/cavium/thunder/thunder_bgx.c  | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 90c718af06c1..9efb60842ad1 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -1493,13 +1493,17 @@ static int bgx_init_of_phy(struct bgx *bgx)
 		 * this cortina phy, for which there is no driver
 		 * support, ignore it.
 		 */
-		if (phy_np &&
-		    !of_device_is_compatible(phy_np, "cortina,cs4223-slice")) {
-			/* Wait until the phy drivers are available */
-			pd = of_phy_find_device(phy_np);
-			if (!pd)
-				goto defer;
-			bgx->lmac[lmac].phydev = pd;
+		if (phy_np) {
+			if (!of_device_is_compatible(phy_np, "cortina,cs4223-slice")) {
+				/* Wait until the phy drivers are available */
+				pd = of_phy_find_device(phy_np);
+				if (!pd) {
+					of_node_put(phy_np);
+					goto defer;
+				}
+				bgx->lmac[lmac].phydev = pd;
+			}
+			of_node_put(phy_np);
 		}
 
 		lmac++;
-- 
2.51.0
Re: [PATCH] net: thunder_bgx: add a missing of_node_put
Posted by Simon Horman 1 month ago
On Mon, Sep 01, 2025 at 02:30:18PM -0700, Rosen Penev wrote:
> phy_np needs to get freed, just like the other child nodes.
> 
> Fixes: 5fc7cf179449 ("net: thunderx: Cleanup PHY probing code.")

I wonder if this leak has existed since commit 4863dea3fab0 ("net: Adding
support for Cavium ThunderX network controller")

> Signed-off-by: Rosen Penev <rosenp@gmail.com>

Otherwise, LGTM.

Reviewed-by: Simon Horman <horms@kernel.org>