Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phy: intel-xway: fix OF node refcount leakage

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>

authored by

Daniel Golle and committed by
Jakub Kicinski
79912b25 b97d5eed

+5 -2
+5 -2
drivers/net/phy/intel-xway.c
··· 277 277 278 278 static int xway_gphy_config_init(struct phy_device *phydev) 279 279 { 280 - struct device_node *np = phydev->mdio.dev.of_node; 280 + struct device_node *np; 281 281 int err; 282 282 283 283 /* Mask all interrupts */ ··· 286 286 return err; 287 287 288 288 /* Use default LED configuration if 'leds' node isn't defined */ 289 - if (!of_get_child_by_name(np, "leds")) 289 + np = of_get_child_by_name(phydev->mdio.dev.of_node, "leds"); 290 + if (np) 291 + of_node_put(np); 292 + else 290 293 xway_gphy_init_leds(phydev); 291 294 292 295 /* Clear all pending interrupts */