Skip to contentSkip to conversation

net: thunder_bgx: Fix refcount leak bug in bgx_init_of_phy()

PATCH In review Liang He 2 participants 2 messages Jul 22, 2022

Subsystems (2)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 net: thunder_bgx: Fix refcount leak bug in bgx_init_of_phy()

We should call of_node_put() for the reference returned by of_parse_phandle() in fail path or when it is not used anymore.

Fixes eee326fd8334 ("net: thunderx: bgx: Use standard firmware node infrastructure.")
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +4 -1
index 2f6484dc186a..1e22cf76374f 100644
@@ -1494,10 +1494,13 @@ static int bgx_init_of_phy(struct bgx *bgx)
 		    !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)
+			if (!pd) {
+				of_node_put(phy_np);
 				goto defer;
+			}
 			bgx->lmac[lmac].phydev = pd;
 		}
+		of_node_put(phy_np);
 
 		lmac++;
 		if (lmac == bgx->max_lmac) {
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#1 lore raw
Quoted 6 lines · On Fri, 22 Jul 2022 23:20:48 +0800 Liang He wrote:

We should call of_node_put() for the reference returned by of_parse_phandle() in fail path or when it is not used anymore.

Fixes eee326fd8334 ("net: thunderx: bgx: Use standard firmware node infrastructure.")

cc netdev@

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel