Commit 48ef5865 authored by Markus Elfring's avatar Markus Elfring Committed by Doug Ledford

IB/qib: Use memdup_user() rather than duplicating its implementation

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

This issue was detected by using the Coccinelle software.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 30b03b15
...@@ -328,26 +328,12 @@ static ssize_t flash_write(struct file *file, const char __user *buf, ...@@ -328,26 +328,12 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
pos = *ppos; pos = *ppos;
if (pos != 0) { if (pos != 0 || count != sizeof(struct qib_flash))
ret = -EINVAL; return -EINVAL;
goto bail;
}
if (count != sizeof(struct qib_flash)) {
ret = -EINVAL;
goto bail;
}
tmp = kmalloc(count, GFP_KERNEL);
if (!tmp) {
ret = -ENOMEM;
goto bail;
}
if (copy_from_user(tmp, buf, count)) { tmp = memdup_user(buf, count);
ret = -EFAULT; if (IS_ERR(tmp))
goto bail_tmp; return PTR_ERR(tmp);
}
dd = private2dd(file); dd = private2dd(file);
if (qib_eeprom_write(dd, pos, tmp, count)) { if (qib_eeprom_write(dd, pos, tmp, count)) {
...@@ -361,8 +347,6 @@ static ssize_t flash_write(struct file *file, const char __user *buf, ...@@ -361,8 +347,6 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
bail_tmp: bail_tmp:
kfree(tmp); kfree(tmp);
bail:
return ret; return ret;
} }
......
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