Message ID | bb710b21-d8c4-e172-63d4-b46c80645cb3@users.sourceforge.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> 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> I like that. Thanks for running that analysis software against s390 KVM code! Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> David -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, 17 Aug 2016 20:08:49 +0200 SF Markus Elfring <elfring@users.sourceforge.net> wrote: > 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. Looks sane, but please take a bit of care about the subject: It's a bit long, and the prefix should be "KVM: s390:". > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > arch/s390/kvm/guestdbg.c | 13 +++---------- > 1 file changed, 3 insertions(+), 10 deletions(-) Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> if Christian wants to apply this (unless I beat him to it). -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/17/2016 02:08 PM, SF Markus Elfring wrote: > 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> I was going to apply this patch, but it probably makes sense to respin the first patch first as suggested to avoid me fixing up the conflicts and then you fixing up the new conflict. So can you respin patch 1,2 as suggested and add the acks/rb for patch 2? > --- > 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) { > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 24 Aug 2016 20:20:02 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Improve determination of sizes
Use memdup_user() rather than duplicating code
arch/s390/kvm/guestdbg.c | 31 +++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)
On 08/24/2016 02:30 PM, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Wed, 24 Aug 2016 20:20:02 +0200 > > A few update suggestions were taken into account > from static source code analysis. > > Markus Elfring (2): > Improve determination of sizes > Use memdup_user() rather than duplicating code > > arch/s390/kvm/guestdbg.c | 31 +++++++++++++------------------ > 1 file changed, 13 insertions(+), 18 deletions(-) > Thanks applied. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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) {