[PATCH] net: phy: Add of_node_put() before return

From: Wan Jiabing
Date: Fri Oct 15 2021 - 03:50:14 EST


Fix following coccicheck warning:
./drivers/net/phy/mdio_bus.c:454:1-33: WARNING: Function
for_each_available_child_of_node should have of_node_put() before return

Early exits from for_each_available_child_of_node should decrement the
node reference counter.

Signed-off-by: Wan Jiabing <wanjiabing@xxxxxxxx>
---
drivers/net/phy/mdio_bus.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index c204067f1890..d19ee8a69e6c 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -460,6 +460,7 @@ static void of_mdiobus_link_mdiodev(struct mii_bus *bus,

if (addr == mdiodev->addr) {
device_set_node(dev, of_fwnode_handle(child));
+ of_node_put(child);
return;
}
}
--
2.20.1