Commit 9f30b674 authored by Fabian Frederick's avatar Fabian Frederick Committed by Christoph Hellwig

bfa: replace 2 kzalloc/copy_from_user by memdup_user

This patch also removes unnecessary printk(KERN_INFO
Signed-off-by: default avatarFabian Frederick <fabf@skynet.be>
Acked-by: default avatarAnil Gurumurthy <anil.gurumurthy@qlogic.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 1b33ef23
...@@ -260,18 +260,9 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf, ...@@ -260,18 +260,9 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
unsigned long flags; unsigned long flags;
void *kern_buf; void *kern_buf;
kern_buf = kzalloc(nbytes, GFP_KERNEL); kern_buf = memdup_user(buf, nbytes);
if (IS_ERR(kern_buf))
if (!kern_buf) { return PTR_ERR(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;
}
rc = sscanf(kern_buf, "%x:%x", &addr, &len); rc = sscanf(kern_buf, "%x:%x", &addr, &len);
if (rc < 2) { if (rc < 2) {
...@@ -336,18 +327,9 @@ bfad_debugfs_write_regwr(struct file *file, const char __user *buf, ...@@ -336,18 +327,9 @@ bfad_debugfs_write_regwr(struct file *file, const char __user *buf,
unsigned long flags; unsigned long flags;
void *kern_buf; void *kern_buf;
kern_buf = kzalloc(nbytes, GFP_KERNEL); kern_buf = memdup_user(buf, nbytes);
if (IS_ERR(kern_buf))
if (!kern_buf) { return PTR_ERR(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;
}
rc = sscanf(kern_buf, "%x:%x", &addr, &val); rc = sscanf(kern_buf, "%x:%x", &addr, &val);
if (rc < 2) { if (rc < 2) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment