summaryrefslogtreecommitdiff
path: root/arch/x86
diff options
context:
space:
mode:
authorMiaohe Lin <linmiaohe@huawei.com>2020-02-21 22:04:46 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-28 17:22:23 +0100
commit7e946e30a46d746237f1df1b0113377e2616dde9 (patch)
tree5f5bb9a4bd555aee77afbd44d238d2965fdfd67e /arch/x86
parentdc5537061baf56f914f0f1339e301a87a8be8d57 (diff)
KVM: apic: avoid calculating pending eoi from an uninitialized val
commit 23520b2def95205f132e167cf5b25c609975e959 upstream. When pv_eoi_get_user() fails, 'val' may remain uninitialized and the return value of pv_eoi_get_pending() becomes random. Fix the issue by initializing the variable. Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/lapic.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 250de598f0fa..5d2587005d0e 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -637,9 +637,11 @@ static inline bool pv_eoi_enabled(struct kvm_vcpu *vcpu)
static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu)
{
u8 val;
- if (pv_eoi_get_user(vcpu, &val) < 0)
+ if (pv_eoi_get_user(vcpu, &val) < 0) {
printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n",
(unsigned long long)vcpu->arch.pv_eoi.msr_val);
+ return false;
+ }
return val & 0x1;
}