summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShivani Gupta <shivani07g@gmail.com>2024-04-23 02:07:27 +0000
committerViresh Kumar <viresh.kumar@linaro.org>2024-04-23 12:51:46 +0530
commitd769eaef2a8d668035e34a19e3282b4222d6e782 (patch)
treeb3241c63c9146493340960ee961a4b0b5c112480
parentb69ec356db1a7c4703b1a9edc82ee1dfdd296b97 (diff)
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 <julia.lawall@inria.fr> Signed-off-by: Shivani Gupta <shivani07g@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
-rw-r--r--drivers/cpufreq/ti-cpufreq.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
index 46c41e2ca727..714ed53753fa 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;
}