Skip to content

Commit fd56d24

Browse files
Li ZefanAl Viro
authored andcommitted
ecryptfs: use memdup_user()
Remove open-coded memdup_user(). Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent a9482eb commit fd56d24

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

‎fs/ecryptfs/miscdev.c‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,18 +418,13 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
418418

419419
if (count == 0)
420420
goto out;
421-
data = kmalloc(count, GFP_KERNEL);
422-
if (!data) {
423-
printk(KERN_ERR "%s: Out of memory whilst attempting to "
424-
"kmalloc([%zd], GFP_KERNEL)\n", __func__, count);
421+
422+
data = memdup_user(buf, count);
423+
if (IS_ERR(data)) {
424+
printk(KERN_ERR "%s: memdup_user returned error [%ld]\n",
425+
__func__, PTR_ERR(data));
425426
goto out;
426427
}
427-
rc = copy_from_user(data, buf, count);
428-
if (rc) {
429-
printk(KERN_ERR "%s: copy_from_user returned error [%d]\n",
430-
__func__, rc);
431-
goto out_free;
432-
}
433428
sz = count;
434429
i = 0;
435430
switch (data[i++]) {

0 commit comments

Comments
 (0)