Skip to content

Commit d769eae

Browse files
shivanigupta-devvireshk
authored andcommitted
cpufreq: ti: Implement scope-based cleanup in ti_cpufreq_match_node()
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 <[email protected]> Signed-off-by: Shivani Gupta <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent b69ec35 commit d769eae

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/cpufreq/ti-cpufreq.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,10 @@ static const struct of_device_id ti_cpufreq_of_match[] = {
347347

348348
static const struct of_device_id *ti_cpufreq_match_node(void)
349349
{
350-
struct device_node *np;
350+
struct device_node *np __free(device_node) = of_find_node_by_path("/");
351351
const struct of_device_id *match;
352352

353-
np = of_find_node_by_path("/");
354353
match = of_match_node(ti_cpufreq_of_match, np);
355-
of_node_put(np);
356354

357355
return match;
358356
}

0 commit comments

Comments
 (0)