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:
Li Zefan 2009-04-08 15:08:04 +08:00 коммит произвёл Al Viro
Родитель 1c8542c7bb
Коммит 0e639bdeef
2 изменённых файлов: 11 добавлений и 24 удалений

Просмотреть файл

@ -489,17 +489,12 @@ xfs_attrmulti_attr_set(
if (len > XATTR_SIZE_MAX) if (len > XATTR_SIZE_MAX)
return EINVAL; return EINVAL;
kbuf = kmalloc(len, GFP_KERNEL); kbuf = memdup_user(ubuf, len);
if (!kbuf) if (IS_ERR(kbuf))
return ENOMEM; return PTR_ERR(kbuf);
if (copy_from_user(kbuf, ubuf, len))
goto out_kfree;
error = xfs_attr_set(XFS_I(inode), name, kbuf, len, flags); error = xfs_attr_set(XFS_I(inode), name, kbuf, len, flags);
out_kfree:
kfree(kbuf);
return error; return error;
} }
@ -540,20 +535,16 @@ xfs_attrmulti_by_handle(
if (!size || size > 16 * PAGE_SIZE) if (!size || size > 16 * PAGE_SIZE)
goto out_dput; goto out_dput;
error = ENOMEM; ops = memdup_user(am_hreq.ops, size);
ops = kmalloc(size, GFP_KERNEL); if (IS_ERR(ops)) {
if (!ops) error = PTR_ERR(ops);
goto out_dput; goto out_dput;
}
error = EFAULT;
if (copy_from_user(ops, am_hreq.ops, size))
goto out_kfree_ops;
attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
if (!attr_name) if (!attr_name)
goto out_kfree_ops; goto out_kfree_ops;
error = 0; error = 0;
for (i = 0; i < am_hreq.opcount; i++) { for (i = 0; i < am_hreq.opcount; i++) {
ops[i].am_error = strncpy_from_user(attr_name, ops[i].am_error = strncpy_from_user(attr_name,

Просмотреть файл

@ -427,20 +427,16 @@ xfs_compat_attrmulti_by_handle(
if (!size || size > 16 * PAGE_SIZE) if (!size || size > 16 * PAGE_SIZE)
goto out_dput; goto out_dput;
error = ENOMEM; ops = memdup_user(compat_ptr(am_hreq.ops), size);
ops = kmalloc(size, GFP_KERNEL); if (IS_ERR(ops)) {
if (!ops) error = PTR_ERR(ops);
goto out_dput; goto out_dput;
}
error = EFAULT;
if (copy_from_user(ops, compat_ptr(am_hreq.ops), size))
goto out_kfree_ops;
attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
if (!attr_name) if (!attr_name)
goto out_kfree_ops; goto out_kfree_ops;
error = 0; error = 0;
for (i = 0; i < am_hreq.opcount; i++) { for (i = 0; i < am_hreq.opcount; i++) {
ops[i].am_error = strncpy_from_user(attr_name, ops[i].am_error = strncpy_from_user(attr_name,