aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdul Hussain <[email protected]>2015-06-16 07:04:51 +0000
committerGreg Kroah-Hartman <[email protected]>2015-06-17 21:30:40 -0700
commit0c027bc378932fa3208c3d847cc1d9b2b98ad725 (patch)
tree4c52495066af1bf294772335c55ab0f088656daf
parentd46bc00c3fac4c1066dd88582f215187436d1711 (diff)
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/staging/lustre/lustre/llite/file.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 4f9b1c796285..3075db211106 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -2361,14 +2361,9 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_state_set *hss;
int rc;
- hss = kzalloc(sizeof(*hss), GFP_NOFS);
- if (!hss)
- return -ENOMEM;
-
- if (copy_from_user(hss, (char *)arg, sizeof(*hss))) {
- kfree(hss);
- return -EFAULT;
- }
+ hss = memdup_user((char *)arg, sizeof(*hss));
+ if (IS_ERR(hss))
+ return PTR_ERR(hss);
rc = ll_hsm_state_set(inode, hss);
@@ -2488,14 +2483,9 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case LL_IOC_HSM_IMPORT: {
struct hsm_user_import *hui;
- hui = kzalloc(sizeof(*hui), GFP_NOFS);
- if (!hui)
- return -ENOMEM;
-
- if (copy_from_user(hui, (void *)arg, sizeof(*hui))) {
- kfree(hui);
- return -EFAULT;
- }
+ hui = memdup_user((void *)arg, sizeof(*hui));
+ if (IS_ERR(hui))
+ return PTR_ERR(hui);
rc = ll_hsm_import(inode, file, hui);