Skip to content

Commit

Permalink
cpufreq: ti: Implement scope-based cleanup in ti_cpufreq_match_node()
Browse files Browse the repository at this point in the history
Modify the ti_cpufreq_match_node() function to utilize the __free()
cleanup handler for automatically releasing the device node when it goes
out of scope.

By moving the declaration to the initialization, the patch ensures that
the device node is properly managed throughout the function's scope,
thus eliminating the need for manual invocation of of_node_put().
This approach reduces the potential for memory leaks.

Suggested-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Shivani Gupta <shivani07g@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
  • Loading branch information
Shivani Gupta authored and Viresh Kumar committed Apr 23, 2024
1 parent b69ec35 commit d769eae
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/cpufreq/ti-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,10 @@ static const struct of_device_id ti_cpufreq_of_match[] = {

static const struct of_device_id *ti_cpufreq_match_node(void)
{
struct device_node *np;
struct device_node *np __free(device_node) = of_find_node_by_path("/");
const struct of_device_id *match;

np = of_find_node_by_path("/");
match = of_match_node(ti_cpufreq_of_match, np);
of_node_put(np);

return match;
}
Expand Down

0 comments on commit d769eae

Please sign in to comment.