]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: phy: intel-xway: fix OF node refcount leakage
authorDaniel Golle <daniel@makrotopia.org>
Mon, 19 Jan 2026 00:41:54 +0000 (00:41 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 20 Jan 2026 23:57:21 +0000 (15:57 -0800)
Automated review spotted am OF node reference count leakage when
checking if the 'leds' child node exists.

Call of_put_node() to correctly maintain the refcount.

Link: https://netdev-ai.bots.linux.dev/ai-review.html?id=20f173ba-0c64-422b-a663-fea4b4ad01d0
Fixes: 1758af47b98c1 ("net: phy: intel-xway: add support for PHY LEDs")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Link: https://patch.msgid.link/e3275e1c1cdca7e6426bb9c11f33bd84b8d900c8.1768783208.git.daniel@makrotopia.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/intel-xway.c

index 9766dd99afaa0a3b4a973c1e2c2fd56486aad78e..12ff4c1f285d24a012426e172eb3af0df99656e5 100644 (file)
@@ -277,7 +277,7 @@ static int xway_gphy_init_leds(struct phy_device *phydev)
 
 static int xway_gphy_config_init(struct phy_device *phydev)
 {
-       struct device_node *np = phydev->mdio.dev.of_node;
+       struct device_node *np;
        int err;
 
        /* Mask all interrupts */
@@ -286,7 +286,10 @@ static int xway_gphy_config_init(struct phy_device *phydev)
                return err;
 
        /* Use default LED configuration if 'leds' node isn't defined */
-       if (!of_get_child_by_name(np, "leds"))
+       np = of_get_child_by_name(phydev->mdio.dev.of_node, "leds");
+       if (np)
+               of_node_put(np);
+       else
                xway_gphy_init_leds(phydev);
 
        /* Clear all pending interrupts */