Skip to content

Commit a2d633c

Browse files
Zijun Huvinodkoul
authored andcommitted
phy: core: Fix an OF node refcount leakage in of_phy_provider_lookup()
For macro for_each_child_of_node(parent, child), refcount of @child has been increased before entering its loop body, so normally needs to call of_node_put(@child) before returning from the loop body to avoid refcount leakage. of_phy_provider_lookup() has such usage but does not call of_node_put() before returning, so cause leakage of the OF node refcount. Fix by simply calling of_node_put() before returning from the loop body. The APIs affected by this issue are shown below since they indirectly invoke problematic of_phy_provider_lookup(). phy_get() of_phy_get() devm_phy_get() devm_of_phy_get() devm_of_phy_get_by_index() Fixes: 2a4c370 ("phy: core: Fix of_phy_provider_lookup to return PHY provider for sub node") Cc: [email protected] Reviewed-by: Johan Hovold <[email protected]> Signed-off-by: Zijun Hu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 5ebdc6b commit a2d633c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/phy/phy-core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
145145
return phy_provider;
146146

147147
for_each_child_of_node(phy_provider->children, child)
148-
if (child == node)
148+
if (child == node) {
149+
of_node_put(child);
149150
return phy_provider;
151+
}
150152
}
151153

152154
return ERR_PTR(-EPROBE_DEFER);

0 commit comments

Comments
 (0)