Commit 4a07594e authored by Abdul Hussain's avatar Abdul Hussain Committed by Greg Kroah-Hartman

Staging: lustre: Use memdup_user rather than duplicating its implementation

This patch uses memdup_user rather than duplicating its implementation
Signed-off-by: default avatarAbdul Hussain <habdul@visteon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0c027bc3
...@@ -1747,15 +1747,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1747,15 +1747,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_user_request *hur; struct hsm_user_request *hur;
ssize_t totalsize; ssize_t totalsize;
hur = kzalloc(sizeof(*hur), GFP_NOFS); hur = memdup_user((void *)arg, sizeof(*hur));
if (!hur) if (IS_ERR(hur))
return -ENOMEM; return PTR_ERR(hur);
/* We don't know the true size yet; copy the fixed-size part */
if (copy_from_user(hur, (void *)arg, sizeof(*hur))) {
kfree(hur);
return -EFAULT;
}
/* Compute the whole struct size */ /* Compute the whole struct size */
totalsize = hur_len(hur); totalsize = hur_len(hur);
...@@ -1833,13 +1827,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1833,13 +1827,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_copy *copy; struct hsm_copy *copy;
int rc; int rc;
copy = kzalloc(sizeof(*copy), GFP_NOFS); copy = memdup_user((char *)arg, sizeof(*copy));
if (!copy) if (IS_ERR(copy))
return -ENOMEM; return PTR_ERR(copy);
if (copy_from_user(copy, (char *)arg, sizeof(*copy))) {
kfree(copy);
return -EFAULT;
}
rc = ll_ioc_copy_start(inode->i_sb, copy); rc = ll_ioc_copy_start(inode->i_sb, copy);
if (copy_to_user((char *)arg, copy, sizeof(*copy))) if (copy_to_user((char *)arg, copy, sizeof(*copy)))
...@@ -1852,13 +1842,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1852,13 +1842,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_copy *copy; struct hsm_copy *copy;
int rc; int rc;
copy = kzalloc(sizeof(*copy), GFP_NOFS); copy = memdup_user((char *)arg, sizeof(*copy));
if (!copy) if (IS_ERR(copy))
return -ENOMEM; return PTR_ERR(copy);
if (copy_from_user(copy, (char *)arg, sizeof(*copy))) {
kfree(copy);
return -EFAULT;
}
rc = ll_ioc_copy_end(inode->i_sb, copy); rc = ll_ioc_copy_end(inode->i_sb, copy);
if (copy_to_user((char *)arg, copy, sizeof(*copy))) if (copy_to_user((char *)arg, copy, sizeof(*copy)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment