From patchwork Sat Jan 7 00:12:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Luczaj X-Patchwork-Id: 13091895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F37EC54EBE for ; Sat, 7 Jan 2023 00:13:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235283AbjAGANU (ORCPT ); Fri, 6 Jan 2023 19:13:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjAGANR (ORCPT ); Fri, 6 Jan 2023 19:13:17 -0500 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [IPv6:2a0c:5a00:149::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EA3A60863 for ; Fri, 6 Jan 2023 16:13:16 -0800 (PST) Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1pDwpm-0047fo-4w for kvm@vger.kernel.org; Sat, 07 Jan 2023 01:13:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rbox.co; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From; bh=hfOySL4v9ZcA9e+DFtF8NhZXTTbBvZWPLHUx9AObm0s=; b=YqX8lIatrkmQb6DHsHn6Nbu+t5 U8xxU207rU2UpU6YecNwPEe/G/DDha5Gge8ytn7EJOrZdEkJCSUpjdW6gNxZ3plEGeUtd8dfF7+0x +rLUdVSTws2gENRIDFVaM15JOutzsBiPf42Fg1n/PCuCkcQS4QS83eggtwu/V6sM8asId82eb/eb3 AFjMZpasJ1c74UcQ9MSlpVNkYE5TV7XLCraQHfjHvQ4qb57TpvfzI6/hH62ZcojHBvs5w+ChiSUA0 kZGbUXJvhlUXQ3HB1z7xczzBl5tKR57Dv2XAe2rPO78T2nS4FJbZbnnSh29PPDuIDjvukZ4RiN9X+ 1Ap2At0Q==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1pDwpl-0002cS-Sh; Sat, 07 Jan 2023 01:13:13 +0100 Received: by submission02.runbox with esmtpsa [Authenticated ID (604044)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1pDwpk-0002mN-ME; Sat, 07 Jan 2023 01:13:12 +0100 From: Michal Luczaj To: kvm@vger.kernel.org Cc: dwmw2@infradead.org, paul@xen.org, seanjc@google.com, pbonzini@redhat.com, Michal Luczaj Subject: [PATCH v2 6/6] KVM: x86: Simplify msr_io() Date: Sat, 7 Jan 2023 01:12:56 +0100 Message-Id: <20230107001256.2365304-7-mhal@rbox.co> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230107001256.2365304-1-mhal@rbox.co> References: <20230107001256.2365304-1-mhal@rbox.co> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org __msr_io() never returns a negative value. Remove unnecessary checks. Signed-off-by: Michal Luczaj --- arch/x86/kvm/x86.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 18d5b82eb46d..555cc1073841 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4285,8 +4285,8 @@ static int msr_io(struct kvm_vcpu *vcpu, struct kvm_msrs __user *user_msrs, { struct kvm_msrs msrs; struct kvm_msr_entry *entries; - int r, n; unsigned size; + int r; r = -EFAULT; if (copy_from_user(&msrs, user_msrs, sizeof(msrs))) @@ -4303,17 +4303,11 @@ static int msr_io(struct kvm_vcpu *vcpu, struct kvm_msrs __user *user_msrs, goto out; } - r = n = __msr_io(vcpu, &msrs, entries, do_msr); - if (r < 0) - goto out_free; + r = __msr_io(vcpu, &msrs, entries, do_msr); - r = -EFAULT; if (writeback && copy_to_user(user_msrs->entries, entries, size)) - goto out_free; - - r = n; + r = -EFAULT; -out_free: kfree(entries); out: return r;