From: Fabian Frederick Date: Fri, 14 Nov 2014 18:49:58 +0000 (+0100) Subject: bfa: replace 2 kzalloc/copy_from_user by memdup_user X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9f30b674759b9a2da25aefe25d885161d8a911cb;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git bfa: replace 2 kzalloc/copy_from_user by memdup_user This patch also removes unnecessary printk(KERN_INFO Signed-off-by: Fabian Frederick Acked-by: Anil Gurumurthy Signed-off-by: Christoph Hellwig --- diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c index 8e83d0474fe7..74a307c0a240 100644 --- a/drivers/scsi/bfa/bfad_debugfs.c +++ b/drivers/scsi/bfa/bfad_debugfs.c @@ -260,18 +260,9 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf, unsigned long flags; void *kern_buf; - kern_buf = kzalloc(nbytes, GFP_KERNEL); - - if (!kern_buf) { - printk(KERN_INFO "bfad[%d]: Failed to allocate buffer\n", - bfad->inst_no); - return -ENOMEM; - } - - if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) { - kfree(kern_buf); - return -ENOMEM; - } + kern_buf = memdup_user(buf, nbytes); + if (IS_ERR(kern_buf)) + return PTR_ERR(kern_buf); rc = sscanf(kern_buf, "%x:%x", &addr, &len); if (rc < 2) { @@ -336,18 +327,9 @@ bfad_debugfs_write_regwr(struct file *file, const char __user *buf, unsigned long flags; void *kern_buf; - kern_buf = kzalloc(nbytes, GFP_KERNEL); - - if (!kern_buf) { - printk(KERN_INFO "bfad[%d]: Failed to allocate buffer\n", - bfad->inst_no); - return -ENOMEM; - } - - if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) { - kfree(kern_buf); - return -ENOMEM; - } + kern_buf = memdup_user(buf, nbytes); + if (IS_ERR(kern_buf)) + return PTR_ERR(kern_buf); rc = sscanf(kern_buf, "%x:%x", &addr, &val); if (rc < 2) {