Skip to content

Commit

Permalink
ncpfs: 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 0e639bd commit a9482eb
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions fs/ncpfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,10 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN)
return -ENOMEM;
if (user.object_name_len) {
newname = kmalloc(user.object_name_len, GFP_USER);
if (!newname)
return -ENOMEM;
if (copy_from_user(newname, user.object_name, user.object_name_len)) {
kfree(newname);
return -EFAULT;
}
newname = memdup_user(user.object_name,
user.object_name_len);
if (IS_ERR(newname))
return PTR_ERR(newname);
} else {
newname = NULL;
}
Expand Down Expand Up @@ -760,13 +757,9 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
if (user.len > NCP_PRIVATE_DATA_MAX_LEN)
return -ENOMEM;
if (user.len) {
new = kmalloc(user.len, GFP_USER);
if (!new)
return -ENOMEM;
if (copy_from_user(new, user.data, user.len)) {
kfree(new);
return -EFAULT;
}
new = memdup_user(user.data, user.len);
if (IS_ERR(new))
return PTR_ERR(new);
} else {
new = NULL;
}
Expand Down

0 comments on commit a9482eb

Please sign in to comment.