From: Paolo Bonzini <pbonzini@redhat.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Wanpeng Li <kernellwp@gmail.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Sean Christopherson <sean.j.christopherson@intel.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
Naresh Kamboju <naresh.kamboju@linaro.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>
Subject: Re: [PATCH] KVM: X86: Fix dereference null cpufreq policy
Date: Mon, 2 Mar 2020 09:39:24 +0100 [thread overview]
Message-ID: <73a7db77-c4c7-029f-fd8a-080911fde41e@redhat.com> (raw)
In-Reply-To: <20200302081207.3kogqwxbkujqgc7z@vireshk-i7>
On 02/03/20 09:12, Viresh Kumar wrote:
> 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).
For the same reason why we support kfree(NULL) and kobject_put(NULL)?
Paolo
next prev parent reply other threads:[~2020-03-02 8:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-02 7:15 Wanpeng Li
2020-03-02 7:55 ` Paolo Bonzini
2020-03-02 8:12 ` Viresh Kumar
2020-03-02 8:39 ` Paolo Bonzini [this message]
2020-03-02 9:14 ` Viresh Kumar
2020-03-02 10:23 ` Paolo Bonzini
2020-03-02 8:58 ` Naresh Kamboju
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=73a7db77-c4c7-029f-fd8a-080911fde41e@redhat.com \
--to=pbonzini@redhat.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=naresh.kamboju@linaro.org \
--cc=rjw@rjwysocki.net \
--cc=sean.j.christopherson@intel.com \
--cc=viresh.kumar@linaro.org \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®