qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] kvm: Potential NULL pointer dereference in kvm_arch


From: Liam Merwick
Subject: [Qemu-devel] [PATCH] kvm: Potential NULL pointer dereference in kvm_arch_init_vcpu()
Date: Wed, 30 Jan 2019 14:49:20 +0000

From: Liam Merwick <address@hidden>

In kvm_arch_init_vcpu() a call to cpuid_find_entry() can return
NULL so the pointer returned should be checked before dereferencing it.

Reported by the Parfait static code analysis tool

Signed-off-by: Liam Merwick <address@hidden>
---
 target/i386/kvm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 9af4542fb8a8..89fac4a5576c 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -1308,7 +1308,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
         c->ecx = c->edx = 0;
 
         c = cpuid_find_entry(&cpuid_data.cpuid, kvm_base, 0);
-        c->eax = MAX(c->eax, KVM_CPUID_SIGNATURE | 0x10);
+        if (c) {
+            c->eax = MAX(c->eax, KVM_CPUID_SIGNATURE | 0x10);
+       }
     }
 
     cpuid_data.cpuid.nent = cpuid_i;
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]