Skip to contentSkip to conversation

phy: core: Fix refcount leak bug in of_phy_provider_lookup()

PATCH New Liang He 1 participant 1 message Jul 15, 2022 Generic PHY framework

lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 phy: core: Fix refcount leak bug in of_phy_provider_lookup()

We should call of_node_put() when breaking out of for_each_child_of_node() as it will automatically increase and decrease the refcount.

Fixes 2a4c37016ca9 ("phy: core: Fix of_phy_provider_lookup to return PHY provider for sub node")
---
 drivers/phy/phy-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/phy/phy-core.c +3 -1
index d93ddf1262c5..47f414c0857d 100644
@@ -138,8 +138,10 @@ static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
 			return phy_provider;
 
 		for_each_child_of_node(phy_provider->children, child)
-			if (child == node)
+			if (child == node) {
+				of_node_put(child);
 				return phy_provider;
+			}
 	}
 
 	return ERR_PTR(-EPROBE_DEFER);
Signature · 7 lines
2.25.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy