Skip to content

Commit 058a399

Browse files
windhlbebarino
authored andcommitted
clk: ti: Balance of_node_get() calls for of_find_node_by_name()
In ti_find_clock_provider(), of_find_node_by_name() will call of_node_put() for the 'from' argument, possibly putting the node one too many times. Let's maintain the of_node_get() from the previous search and only put when we're exiting the function early. This should avoid a misbalanced reference count on the node. Fixes: 51f661e ("clk: ti: Add ti_find_clock_provider() to use clock-output-names") Signed-off-by: Liang He <windhl@126.com> Link: https://lore.kernel.org/r/20220915031121.4003589-1-windhl@126.com [sboyd@kernel.org: Rewrite commit text, maintain reference instead of get again] Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 4e343ba commit 058a399

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/clk/ti/clk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
139139
break;
140140
}
141141
}
142-
of_node_put(from);
143142
kfree(tmp);
144143

145-
if (found)
144+
if (found) {
145+
of_node_put(from);
146146
return np;
147+
}
147148

148149
/* Fall back to using old node name base provider name */
149150
return of_find_node_by_name(from, name);

0 commit comments

Comments
 (0)