ncpfs: 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>
This commit is contained in:
parent
0e639bdeef
commit
a9482ebcde
1 changed files with 7 additions and 14 deletions
|
@ -660,13 +660,10 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
|
||||||
if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN)
|
if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
if (user.object_name_len) {
|
if (user.object_name_len) {
|
||||||
newname = kmalloc(user.object_name_len, GFP_USER);
|
newname = memdup_user(user.object_name,
|
||||||
if (!newname)
|
user.object_name_len);
|
||||||
return -ENOMEM;
|
if (IS_ERR(newname))
|
||||||
if (copy_from_user(newname, user.object_name, user.object_name_len)) {
|
return PTR_ERR(newname);
|
||||||
kfree(newname);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
newname = NULL;
|
newname = NULL;
|
||||||
}
|
}
|
||||||
|
@ -760,13 +757,9 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
|
||||||
if (user.len > NCP_PRIVATE_DATA_MAX_LEN)
|
if (user.len > NCP_PRIVATE_DATA_MAX_LEN)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
if (user.len) {
|
if (user.len) {
|
||||||
new = kmalloc(user.len, GFP_USER);
|
new = memdup_user(user.data, user.len);
|
||||||
if (!new)
|
if (IS_ERR(new))
|
||||||
return -ENOMEM;
|
return PTR_ERR(new);
|
||||||
if (copy_from_user(new, user.data, user.len)) {
|
|
||||||
kfree(new);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
new = NULL;
|
new = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue