Message ID | 1583069198-21060-1-git-send-email-qiwuchen55@gmail.com (mailing list archive) |
---|---|
State | Rejected, archived |
Headers | show |
Series | cpufreq: fix a mem leak caused by policy->max_freq_req in cpufreq_policy_free() | expand |
On Sun, Mar 1, 2020 at 2:26 PM <qiwuchen55@gmail.com> wrote: > > From: chenqiwu <chenqiwu@xiaomi.com> > > There is a mem leak in cpufreq_policy_free() that the resource of > policy->max_freq_req pointer is not free. That's incorrect AFAICS. Thanks! > Signed-off-by: chenqiwu <chenqiwu@xiaomi.com> > --- > drivers/cpufreq/cpufreq.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index cbe6c94..6756f7a 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -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 >
On 01-03-20, 21:09, Rafael J. Wysocki wrote: > On Sun, Mar 1, 2020 at 2:26 PM <qiwuchen55@gmail.com> wrote: > > > > From: chenqiwu <chenqiwu@xiaomi.com> > > > > There is a mem leak in cpufreq_policy_free() that the resource of > > policy->max_freq_req pointer is not free. > > That's incorrect AFAICS. +1 > Thanks! > > > Signed-off-by: chenqiwu <chenqiwu@xiaomi.com> > > --- > > drivers/cpufreq/cpufreq.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > > index cbe6c94..6756f7a 100644 > > --- a/drivers/cpufreq/cpufreq.c > > +++ b/drivers/cpufreq/cpufreq.c > > @@ -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.
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index cbe6c94..6756f7a 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -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);