From: Shivani Gupta Date: Tue, 23 Apr 2024 02:07:27 +0000 (+0000) Subject: cpufreq: ti: Implement scope-based cleanup in ti_cpufreq_match_node() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d769eaef2a8d668035e34a19e3282b4222d6e782;p=linux.git 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 Signed-off-by: Shivani Gupta Signed-off-by: Viresh Kumar --- diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c index 46c41e2ca727b..714ed53753fa5 100644 --- a/drivers/cpufreq/ti-cpufreq.c +++ b/drivers/cpufreq/ti-cpufreq.c @@ -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; }