[PATCH] net: thunder_bgx: Fix refcount leak bug in bgx_init_of_phy()
Liang He
windhl at 126.com
Fri Jul 22 08:20:48 PDT 2022
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.")
Signed-off-by: Liang He <windhl at 126.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 2f6484dc186a..1e22cf76374f 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -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) {
--
2.25.1
More information about the linux-arm-kernel
mailing list