From patchwork Thu Feb 20 15:36:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 11394325 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 742EA13A4 for ; Thu, 20 Feb 2020 15:36:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DDC0207FD for ; Thu, 20 Feb 2020 15:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728493AbgBTPgH (ORCPT ); Thu, 20 Feb 2020 10:36:07 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:52248 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728319AbgBTPgH (ORCPT ); Thu, 20 Feb 2020 10:36:07 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E30F47E11A4E9CF39F13; Thu, 20 Feb 2020 23:35:53 +0800 (CST) Received: from huawei.com (10.175.105.18) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Thu, 20 Feb 2020 23:35:12 +0800 From: linmiaohe To: , , , , , , , , , , CC: , , , Subject: [PATCH] KVM: apic: avoid calculating pending eoi from an uninitialized val Date: Thu, 20 Feb 2020 23:36:46 +0800 Message-ID: <1582213006-488-1-git-send-email-linmiaohe@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.105.18] X-CFilter-Loop: Reflected Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Miaohe Lin When get user eoi value failed, var val would be uninitialized and result in calculating pending eoi from an uninitialized val. Initialize var val to 0 to fix this case. Signed-off-by: Miaohe Lin Reviewed-by: Vitaly Kuznetsov --- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 4f14ec7525f6..7e77e94f3176 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -626,7 +626,7 @@ static inline bool pv_eoi_enabled(struct kvm_vcpu *vcpu) static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu) { - u8 val; + u8 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);