Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1464702

[PATCH 2/4] KVM-S390: Use memdup_user() rather than duplicating its implementation

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 2/4] KVM-S390: Use memdup_user() rather than duplicating its implementation
Date 2016-08-17 20:20 +0200
Message-ID <s7dBv-4DV-9@gated-at.bofh.it> (permalink)
References <s7drP-4Al-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 17 Aug 2016 18:41:43 +0200

* Reuse existing functionality from memdup_user() instead of keeping
  duplicate source code.

  This issue was detected by using the Coccinelle software.

* Return directly if this copy operation failed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kvm/guestdbg.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c
index b68db4b..8f886ee 100644
--- a/arch/s390/kvm/guestdbg.c
+++ b/arch/s390/kvm/guestdbg.c
@@ -217,16 +217,9 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
 		return -EINVAL;
 
 	size = dbg->arch.nr_hw_bp * sizeof(*bp_data);
-	bp_data = kmalloc(size, GFP_KERNEL);
-	if (!bp_data) {
-		ret = -ENOMEM;
-		goto error;
-	}
-
-	if (copy_from_user(bp_data, dbg->arch.hw_bp, size)) {
-		ret = -EFAULT;
-		goto error;
-	}
+	bp_data = memdup_user(dbg->arch.hw_bp, size);
+	if (IS_ERR(bp_data))
+		return PTR_ERR(bp_data);
 
 	for (i = 0; i < dbg->arch.nr_hw_bp; i++) {
 		switch (bp_data[i].type) {
-- 
2.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] KVM-S390: Fine-tuning for kvm_s390_import_bp_data() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-17 20:10 +0200
  [PATCH 2/4] KVM-S390: Use memdup_user() rather than duplicating its  implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-17 20:20 +0200
    Re: [PATCH 2/4] KVM-S390: Use memdup_user() rather than duplicating  its implementation Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-08-22 15:10 +0200
    Re: [PATCH 2/4] KVM-S390: Use memdup_user() rather than duplicating  its implementation David Hildenbrand <dahi@linux.vnet.ibm.com> - 2016-08-22 15:10 +0200
    Re: [PATCH 2/4] KVM-S390: Use memdup_user() rather than duplicating  its implementation Christian Borntraeger <borntraeger@de.ibm.com> - 2016-08-24 17:20 +0200
      [PATCH v2 0/2] KVM: s390: Fine-tuning for kvm_s390_import_bp_data() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-24 20:40 +0200
        [PATCH v2 1/2] KVM: s390: Improve determination of sizes in  kvm_s390_import_bp_data() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-24 20:50 +0200
        [PATCH v2 2/2] KVM: s390: Use memdup_user() rather than duplicating  code SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-24 20:50 +0200
  [PATCH 3/4] KVM-S390: Less function calls in  kvm_s390_import_bp_data() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-17 20:20 +0200
    Re: [PATCH 3/4] KVM-S390: Less function calls in  kvm_s390_import_bp_data() after error detection David Hildenbrand <dahi@linux.vnet.ibm.com> - 2016-08-22 15:00 +0200
    Re: [PATCH 3/4] KVM-S390: Less function calls in  kvm_s390_import_bp_data() after error detection Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-08-22 15:10 +0200
      Re: [PATCH 3/4] KVM-S390: Less function calls in  kvm_s390_import_bp_data() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-22 19:00 +0200
        Re: [PATCH 3/4] KVM-S390: Less function calls in  kvm_s390_import_bp_data() after error detection Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-08-22 21:40 +0200
          Re: [PATCH 3/4] KVM-S390: Less function calls in  kvm_s390_import_bp_data() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-22 23:20 +0200
            Re: [PATCH 3/4] KVM-S390: Less function calls in  kvm_s390_import_bp_data() after error detection Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-08-22 23:30 +0200
    Re: [PATCH 3/4] KVM-S390: Less function calls in  kvm_s390_import_bp_data() after error detection Christian Borntraeger <borntraeger@de.ibm.com> - 2016-08-24 17:20 +0200
  [PATCH 4/4] KVM-S390: Delete an unnecessary initialisation for a  buffer variable SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-17 20:20 +0200
    Re: [PATCH 4/4] KVM-S390: Delete an unnecessary initialisation for  a buffer variable Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-08-22 15:10 +0200
    Re: [PATCH 4/4] KVM-S390: Delete an unnecessary initialisation for  a buffer variable David Hildenbrand <dahi@linux.vnet.ibm.com> - 2016-08-22 15:10 +0200
  [PATCH 1/4] KVM-S390: Improve determination of sizes in  kvm_s390_import_bp_data() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-17 20:20 +0200
    Re: [PATCH 1/4] KVM-S390: Improve determination of sizes in kvm_s390_import_bp_data() walter harms <wharms@bfs.de> - 2016-08-18 09:30 +0200
      Re: [PATCH 1/4] KVM-S390: Improve determination of sizes in  kvm_s390_import_bp_data() Julia Lawall <julia.lawall@lip6.fr> - 2016-08-18 11:10 +0200
        Re: [PATCH 1/4] KVM-S390: Improve determination of sizes in  kvm_s390_import_bp_data() Paolo Bonzini <pbonzini@redhat.com> - 2016-08-18 12:10 +0200
          Re: [PATCH 1/4] KVM-S390: Improve determination of sizes in kvm_s390_import_bp_data() walter harms <wharms@bfs.de> - 2016-08-18 13:00 +0200
            Re: [PATCH 1/4] KVM-S390: Improve determination of sizes in  kvm_s390_import_bp_data() Paolo Bonzini <pbonzini@redhat.com> - 2016-08-18 13:10 +0200
              Re: [PATCH 1/4] KVM-S390: Improve determination of sizes in  kvm_s390_import_bp_data() Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-08-22 15:00 +0200
          Re: Replacing specific kmalloc() calls by kmalloc_array()? SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-24 14:20 +0200
            Re: Replacing specific kmalloc() calls by kmalloc_array()? Paolo Bonzini <pbonzini@redhat.com> - 2016-08-24 17:10 +0200

csiph-web