lkml.org 
[lkml]   [2020]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] KVM: X86: Fix dereference null cpufreq policy
On 02-03-20, 08:55, Paolo Bonzini wrote:
> On 02/03/20 08:15, Wanpeng Li wrote:
> > From: Wanpeng Li <wanpengli@tencent.com>
> >
> > cpufreq policy which is get by cpufreq_cpu_get() can be NULL if it is failure,
> > this patch takes care of it.
> >
> > Fixes: aaec7c03de (KVM: x86: avoid useless copy of cpufreq policy)
> > Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> > Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
> > Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
>
> My bad, I checked kobject_put but didn't check that kobj is first in
> struct cpufreq_policy.
>
> I think we should do this in cpufreq_cpu_put or, even better, move the
> kobject struct first in struct cpufreq_policy. Rafael, Viresh, any
> objection?
>
> Paolo
>
> > policy = cpufreq_cpu_get(cpu);
> > - if (policy && policy->cpuinfo.max_freq)
> > - max_tsc_khz = policy->cpuinfo.max_freq;
> > + if (policy) {
> > + if (policy->cpuinfo.max_freq)
> > + max_tsc_khz = policy->cpuinfo.max_freq;
> > + cpufreq_cpu_put(policy);
> > + }

I think this change makes sense and I am not sure why should we even
try to support cpufreq_cpu_put(NULL).

--
viresh

\
 
 \ /
  Last update: 2020-03-02 09:13    [W:0.050 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site