linux-mips
[Top] [All Lists]

[PATCH v2] MIPS: KVM: Return directly after a failed copy_from_user() in

To: kvm@vger.kernel.org, linux-mips@linux-mips.org, James Hogan <james.hogan@imgtec.com>, Paolo Bonzini <pbonzini@redhat.com>, Radim Krčmář <rkrcmar@redhat.com>, Ralf Bächle <ralf@linux-mips.org>
Subject: [PATCH v2] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 19 Jan 2017 11:20:40 +0100
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
In-reply-to: <88b008c5-552b-7314-94d8-02214f38a456@redhat.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <87aac8b8-4f30-2edd-4688-42d32d815cd1@users.sourceforge.net> <88b008c5-552b-7314-94d8-02214f38a456@redhat.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 19 Jan 2017 11:10:26 +0100

* Return directly after a call of the function "copy_from_user" failed
  in a case block.

* Delete the jump label "out" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

V2:
A label was also removed at the end.

 arch/mips/kvm/mips.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 06a60b19acfb..3534a0b9efed 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -1152,10 +1152,8 @@ long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int 
ioctl,
                {
                        struct kvm_mips_interrupt irq;
 
-                       r = -EFAULT;
                        if (copy_from_user(&irq, argp, sizeof(irq)))
-                               goto out;
-
+                               return -EFAULT;
                        kvm_debug("[%d] %s: irq: %d\n", vcpu->vcpu_id, __func__,
                                  irq.irq);
 
@@ -1165,17 +1163,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp, unsigned 
int ioctl,
        case KVM_ENABLE_CAP: {
                struct kvm_enable_cap cap;
 
-               r = -EFAULT;
                if (copy_from_user(&cap, argp, sizeof(cap)))
-                       goto out;
+                       return -EFAULT;
                r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap);
                break;
        }
        default:
                r = -ENOIOCTLCMD;
        }
-
-out:
        return r;
 }
 
-- 
2.11.0


<Prev in Thread] Current Thread [Next in Thread>