* [PATCH] KVM: x86: remove dead initialization
@ 2021-08-09 11:01 Paolo Bonzini
2021-08-09 17:05 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2021-08-09 11:01 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: kernel test robot
hv_vcpu is initialized again a dozen lines below, so remove the
initializer.
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: x86: remove dead initialization
2021-08-09 11:01 [PATCH] KVM: x86: remove dead initialization Paolo Bonzini
@ 2021-08-09 17:05 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2021-08-09 17:05 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: linux-kernel, kvm, kernel test robot
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-09 17:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 11:01 [PATCH] KVM: x86: remove dead initialization Paolo Bonzini
2021-08-09 17:05 ` Sean Christopherson
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).