From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC9FEC2BBE2 for ; Sat, 7 Dec 2019 09:25:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8348E2467B for ; Sat, 7 Dec 2019 09:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbfLGJZr (ORCPT ); Sat, 7 Dec 2019 04:25:47 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:44666 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726263AbfLGJZq (ORCPT ); Sat, 7 Dec 2019 04:25:46 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id DEFC41FF1843BB005282; Sat, 7 Dec 2019 17:25:41 +0800 (CST) Received: from huawei.com (10.175.105.18) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Sat, 7 Dec 2019 17:25:34 +0800 From: linmiaohe To: , , , , , , , , , , CC: , , , Subject: [PATCH 3/6] KVM: x86: remove always equal to 0 return val of kvm_vm_ioctl_get_pit2() Date: Sat, 7 Dec 2019 17:25:20 +0800 Message-ID: <1575710723-32094-4-git-send-email-linmiaohe@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575710723-32094-1-git-send-email-linmiaohe@huawei.com> References: <1575710723-32094-1-git-send-email-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.105.18] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaohe Lin The return val of kvm_vm_ioctl_get_pit2() is always equal to 0, which means there is no way to failed with this function. So remove the return val as it's unnecessary to check against it. Also add BUILD_BUG_ON to guard against channels size changed unexpectly. Signed-off-by: Miaohe Lin --- arch/x86/kvm/x86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5628dceb9fa5..637d5c6b92be 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4621,15 +4621,17 @@ static void kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps) mutex_unlock(&pit->pit_state.lock); } -static int kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) +static void kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) { + BUILD_BUG_ON(sizeof(ps->channels) != + sizeof(kvm->arch.vpit->pit_state.channels)); + mutex_lock(&kvm->arch.vpit->pit_state.lock); memcpy(ps->channels, &kvm->arch.vpit->pit_state.channels, sizeof(ps->channels)); ps->flags = kvm->arch.vpit->pit_state.flags; mutex_unlock(&kvm->arch.vpit->pit_state.lock); memset(&ps->reserved, 0, sizeof(ps->reserved)); - return 0; } static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) @@ -5003,9 +5005,7 @@ long kvm_arch_vm_ioctl(struct file *filp, r = -ENXIO; if (!kvm->arch.vpit) goto out; - r = kvm_vm_ioctl_get_pit2(kvm, &u.ps2); - if (r) - goto out; + kvm_vm_ioctl_get_pit2(kvm, &u.ps2); r = -EFAULT; if (copy_to_user(argp, &u.ps2, sizeof(u.ps2))) goto out; -- 2.19.1