kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] KVM: always initialize *pdata in get_msr()
@ 2015-01-23 14:32 Dan Carpenter
  2015-01-23 16:08 ` Radim Krčmář
  2015-01-23 17:50 ` Paolo Bonzini
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-01-23 14:32 UTC (permalink / raw)
  To: Gleb Natapov
  Cc: Paolo Bonzini, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	kvm, kernel-janitors

Smatch complains that there are some paths where we use uninitialized
data in em_sysenter().

        arch/x86/kvm/emulate.c:2410 em_sysenter()
        error: potentially using uninitialized 'msr_data'.

A couple examples of paths which don't set "pdata" are found in
get_msr_hyperv() and kvm_x2apic_msr_read().  I looked at this code and
it seems like setting it to zero is a common default behaviour.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
From static analysis only, not from real life.

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index a17d848..f0e30d2 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3063,6 +3063,8 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 *data)
 {
 	struct vcpu_svm *svm = to_svm(vcpu);
 
+	*data = 0;
+
 	switch (ecx) {
 	case MSR_IA32_TSC: {
 		*data = svm->vmcb->control.tsc_offset +
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ce35071..3bdb9ca 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2544,6 +2544,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
 		printk(KERN_ERR "BUG: get_msr called with NULL pdata\n");
 		return -EINVAL;
 	}
+	*pdata = 0;
 
 	switch (msr_index) {
 #ifdef CONFIG_X86_64

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-24  9:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-23 14:32 [patch] KVM: always initialize *pdata in get_msr() Dan Carpenter
2015-01-23 16:08 ` Radim Krčmář
2015-01-24  9:26   ` Dan Carpenter
2015-01-23 17:50 ` Paolo Bonzini

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).