Skip to content

Commit

Permalink
clk: ti: Balance of_node_get() calls for of_find_node_by_name()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[[email protected]: Rewrite commit text, maintain reference instead of
get again]
Signed-off-by: Stephen Boyd <[email protected]>
  • Loading branch information
windhl authored and bebarino committed Oct 1, 2022
1 parent 4e343ba commit 058a399
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/clk/ti/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,12 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
break;
}
}
of_node_put(from);
kfree(tmp);

if (found)
if (found) {
of_node_put(from);
return np;
}

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

0 comments on commit 058a399

Please sign in to comment.