summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAbdul Hussain <habdul@visteon.com>2015-06-16 07:05:17 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-06-18 04:30:40 (GMT)
commit4a07594e702cfa12efb2177c9a2eb347c7cb84f9 (patch)
treed3c0900c55479b0952b1fa0d2c644a8613ace9a6 /drivers
parent0c027bc378932fa3208c3d847cc1d9b2b98ad725 (diff)
downloadlinux-4a07594e702cfa12efb2177c9a2eb347c7cb84f9.tar.xz
Staging: lustre: Use memdup_user rather than duplicating its implementation
This patch uses memdup_user rather than duplicating its implementation Signed-off-by: Abdul Hussain <habdul@visteon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/lustre/lustre/llite/dir.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index c2eb4f2..3d746a9 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1747,15 +1747,9 @@ out_quotactl:
struct hsm_user_request *hur;
ssize_t totalsize;
- hur = kzalloc(sizeof(*hur), GFP_NOFS);
- if (!hur)
- return -ENOMEM;
-
- /* 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;
- }
+ hur = memdup_user((void *)arg, sizeof(*hur));
+ if (IS_ERR(hur))
+ return PTR_ERR(hur);
/* Compute the whole struct size */
totalsize = hur_len(hur);
@@ -1833,13 +1827,9 @@ out_quotactl:
struct hsm_copy *copy;
int rc;
- copy = kzalloc(sizeof(*copy), GFP_NOFS);
- if (!copy)
- return -ENOMEM;
- if (copy_from_user(copy, (char *)arg, sizeof(*copy))) {
- kfree(copy);
- return -EFAULT;
- }
+ copy = memdup_user((char *)arg, sizeof(*copy));
+ if (IS_ERR(copy))
+ return PTR_ERR(copy);
rc = ll_ioc_copy_start(inode->i_sb, copy);
if (copy_to_user((char *)arg, copy, sizeof(*copy)))
@@ -1852,13 +1842,9 @@ out_quotactl:
struct hsm_copy *copy;
int rc;
- copy = kzalloc(sizeof(*copy), GFP_NOFS);
- if (!copy)
- return -ENOMEM;
- if (copy_from_user(copy, (char *)arg, sizeof(*copy))) {
- kfree(copy);
- return -EFAULT;
- }
+ copy = memdup_user((char *)arg, sizeof(*copy));
+ if (IS_ERR(copy))
+ return PTR_ERR(copy);
rc = ll_ioc_copy_end(inode->i_sb, copy);
if (copy_to_user((char *)arg, copy, sizeof(*copy)))