summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKsenija Stanojevic <ksenija.stanojevic@gmail.com>2015-10-09 15:56:59 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-12 20:35:21 -0700
commit4ecc4a18d987e7e9f4b7eff2bf9215ac02c8a980 (patch)
tree195e87d5c31211cda26cd45881d7bbde7edddf3d
parent514d4d744d5c40aed94c4424a715227698935be9 (diff)
downloadlinux-4ecc4a18d987e7e9f4b7eff2bf9215ac02c8a980.tar.bz2
Staging: rdma: Use memdup_user
Use memdup_user when user data is immediately copied into the allocated region. Issue found using coccinelle. Signed-off-by: Ksenija Stanojevic<ksenija.stanojevic@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/rdma/ipath/ipath_fs.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/staging/rdma/ipath/ipath_fs.c b/drivers/staging/rdma/ipath/ipath_fs.c
index 25422a3a7238..796af6867007 100644
--- a/drivers/staging/rdma/ipath/ipath_fs.c
+++ b/drivers/staging/rdma/ipath/ipath_fs.c
@@ -195,16 +195,9 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
goto bail;
}
- tmp = kmalloc(count, GFP_KERNEL);
- if (!tmp) {
- ret = -ENOMEM;
- goto bail;
- }
-
- if (copy_from_user(tmp, buf, count)) {
- ret = -EFAULT;
- goto bail_tmp;
- }
+ tmp = memdup_user(buf, count);
+ if (IS_ERR(tmp))
+ return PTR_ERR(tmp);
dd = file_inode(file)->i_private;
if (ipath_eeprom_write(dd, pos, tmp, count)) {