Skip to content

Commit a9482eb

Browse files
Li ZefanAl Viro
authored andcommitted
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>
1 parent 0e639bd commit a9482eb

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

‎fs/ncpfs/ioctl.c‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -660,13 +660,10 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
660660
if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN)
661661
return -ENOMEM;
662662
if (user.object_name_len) {
663-
newname = kmalloc(user.object_name_len, GFP_USER);
664-
if (!newname)
665-
return -ENOMEM;
666-
if (copy_from_user(newname, user.object_name, user.object_name_len)) {
667-
kfree(newname);
668-
return -EFAULT;
669-
}
663+
newname = memdup_user(user.object_name,
664+
user.object_name_len);
665+
if (IS_ERR(newname))
666+
return PTR_ERR(newname);
670667
} else {
671668
newname = NULL;
672669
}
@@ -760,13 +757,9 @@ static int __ncp_ioctl(struct inode *inode, struct file *filp,
760757
if (user.len > NCP_PRIVATE_DATA_MAX_LEN)
761758
return -ENOMEM;
762759
if (user.len) {
763-
new = kmalloc(user.len, GFP_USER);
764-
if (!new)
765-
return -ENOMEM;
766-
if (copy_from_user(new, user.data, user.len)) {
767-
kfree(new);
768-
return -EFAULT;
769-
}
760+
new = memdup_user(user.data, user.len);
761+
if (IS_ERR(new))
762+
return PTR_ERR(new);
770763
} else {
771764
new = NULL;
772765
}

0 commit comments

Comments
 (0)