From: Liam Merwick <liam.merwick@oracle.com>
To: rth@twiddle.net, ehabkost@redhat.com, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, mtosatti@redhat.com, liam.merwick@oracle.com
Subject: [Qemu-devel] [PATCH] kvm: Potential NULL pointer dereference in kvm_arch_init_vcpu()
Date: Wed, 30 Jan 2019 14:49:20 +0000 [thread overview]
Message-ID: <1548859760-10654-1-git-send-email-liam.merwick@oracle.com> (raw)
From: Liam Merwick <Liam.Merwick@oracle.com>
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 <Liam.Merwick@oracle.com>
---
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
next reply other threads:[~2019-01-30 14:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-30 14:49 Liam Merwick [this message]
2019-01-30 15:20 ` [Qemu-devel] [PATCH] kvm: Potential NULL pointer dereference in kvm_arch_init_vcpu() Paolo Bonzini
2019-01-31 18:01 ` no-reply
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=1548859760-10654-1-git-send-email-liam.merwick@oracle.com \
--to=liam.merwick@oracle.com \
--cc=ehabkost@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).