cpufreq: fix a mem leak caused by policy->max_freq_req in cpufreq_policy_free()
PATCH 1/1 cpufreq: fix a mem leak caused by policy->max_freq_req in cpufreq_policy_free()
From: chenqiwu <[email protected]>
There is a mem leak in cpufreq_policy_free() that the resource of policy->max_freq_req pointer is not free.
--- drivers/cpufreq/cpufreq.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/cpufreq/cpufreq.c +2 -0
@@ -1280,6 +1280,8 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)blocking_notifier_call_chain (&cpufreq_policy_notifier_list,CPUFREQ_REMOVE_POLICY , policy);freq_qos_remove_request (policy->max_freq_req); +kfree (policy->max_freq_req); + policy->max_freq_req =NULL ; }freq_qos_remove_request (policy->min_freq_req);
Signature · 1 line
1.9.1
Rafael J. Wysocki
maintainerQuoted 5 lines · On Sun, Mar 1, 2020 at 2:26 PM <[email protected]> wrote:
From: chenqiwu <[email protected]>
There is a mem leak in
cpufreq_policy_free()that the resource ofpolicy->max_freq_reqpointer is not free.
That's incorrect AFAICS.
Thanks!
Quoted 21 lines
Signed-off-by chenqiwu <[email protected]>--- drivers/cpufreq/cpufreq.c | 2 ++ 1 file changed, 2 insertions(+)drivers/cpufreq/cpufreq.c +2
-1@@ -1280,6 +1280,8 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)blocking_notifier_call_chain (&cpufreq_policy_notifier_list,CPUFREQ_REMOVE_POLICY , policy);freq_qos_remove_request (policy->max_freq_req); +kfree (policy->max_freq_req); + policy->max_freq_req =NULL ; }freq_qos_remove_request (policy->min_freq_req); --1.9.1
Viresh Kumar
maintainerQuoted 8 lines · Rafael J. Wysocki
Quoted 5 lines · On Sun, Mar 1, 2020 at 2:26 PM <[email protected]> wrote:
From: chenqiwu <[email protected]>
There is a mem leak in
cpufreq_policy_free()that the resource ofpolicy->max_freq_reqpointer is not free.That's incorrect AFAICS.
+1
Quoted 7 lines
Thanks!
Quoted 5 lines
Signed-off-by chenqiwu <[email protected]>--- drivers/cpufreq/cpufreq.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 10 lines
drivers/cpufreq/cpufreq.c static void cpufreq_policy_free(struct cpufreq_policy *policy) · line 1284
Quoted 10 lines
drivers/cpufreq/cpufreq.c +2
-0@@ -1280,6 +1280,8 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)blocking_notifier_call_chain (&cpufreq_policy_notifier_list,CPUFREQ_REMOVE_POLICY , policy);freq_qos_remove_request (policy->max_freq_req); +kfree (policy->max_freq_req); + policy->max_freq_req =NULL ;
Memory for both min_freq_req and max_freq_req is allocated together and so we don't need to free max_freq_req separately.
Signature · 1 line
viresh