Skip to content

Commit

Permalink
ecryptfs: use memdup_user()
Browse files Browse the repository at this point in the history
Remove open-coded memdup_user().

Signed-off-by: Li Zefan <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Li Zefan authored and Al Viro committed Apr 21, 2009
1 parent a9482eb commit fd56d24
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions fs/ecryptfs/miscdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,18 +418,13 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,

if (count == 0)
goto out;
data = kmalloc(count, GFP_KERNEL);
if (!data) {
printk(KERN_ERR "%s: Out of memory whilst attempting to "
"kmalloc([%zd], GFP_KERNEL)\n", __func__, count);

data = memdup_user(buf, count);
if (IS_ERR(data)) {
printk(KERN_ERR "%s: memdup_user returned error [%ld]\n",
__func__, PTR_ERR(data));
goto out;
}
rc = copy_from_user(data, buf, count);
if (rc) {
printk(KERN_ERR "%s: copy_from_user returned error [%d]\n",
__func__, rc);
goto out_free;
}
sz = count;
i = 0;
switch (data[i++]) {
Expand Down

0 comments on commit fd56d24

Please sign in to comment.