From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] KVM: x86: remove dead initialization
Date: Mon, 9 Aug 2021 17:05:51 +0000 [thread overview]
Message-ID: <YRFgb5AbeL8fprgc@google.com> (raw)
In-Reply-To: <20210809110120.3237065-1-pbonzini@redhat.com>
On Mon, Aug 09, 2021, Paolo Bonzini wrote:
> hv_vcpu is initialized again a dozen lines below, so remove the
> initializer.
Eewwww. It's not just dead code, it's code that could potentially lead to
dereferncing a NULL pointer and/or a stale pointer. The second initialization
of the local hv_vcpu happens after a conditional call to kvm_hv_vcpu_init().
Maybe update the changelog to clarify why the second initialization absolutely
must be kept?
For the code:
Reviewed-by: Sean Christopherson <seanjc@google.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/x86/kvm/hyperv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index e9582db29a99..2da21e45da99 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -1968,7 +1968,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc, bool
> void kvm_hv_set_cpuid(struct kvm_vcpu *vcpu)
> {
> struct kvm_cpuid_entry2 *entry;
> - struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu);
> + struct kvm_vcpu_hv *hv_vcpu;
>
> entry = kvm_find_cpuid_entry(vcpu, HYPERV_CPUID_INTERFACE, 0);
> if (entry && entry->eax == HYPERV_CPUID_SIGNATURE_EAX) {
> --
> 2.27.0
>
prev parent reply other threads:[~2021-08-09 17:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-09 11:01 [PATCH] KVM: x86: remove dead initialization Paolo Bonzini
2021-08-09 17:05 ` Sean Christopherson [this message]
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=YRFgb5AbeL8fprgc@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=pbonzini@redhat.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;
as well as URLs for NNTP newsgroup(s).