mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Staging: lustre: Use memdup_user rather than duplicating its implementation
@ 2015-06-16  7:04 Abdul, Hussain (H.)
  0 siblings, 0 replies; 2+ messages in thread
From: Abdul, Hussain (H.) @ 2015-06-16  7:04 UTC (permalink / raw)
  To: gregkh
  Cc: oleg.drokin, andreas.dilger, HPDD-discuss@lists.01.org, devel,
	linux-kernel, Ravindran, Madhusudhanan (M.), Dighe, Niranjan (N.)

From: Abdul Hussain <habdul@visteon.com>

This patch uses memdup_user rather than duplicating its implementation

Signed-off-by: Abdul Hussain <habdul@visteon.com>
---
 drivers/staging/lustre/lustre/llite/file.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 4f9b1c7..3075db2 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);
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] Staging: lustre: Use memdup_user rather than duplicating its implementation
@ 2015-06-16  7:05 Abdul, Hussain (H.)
  0 siblings, 0 replies; 2+ messages in thread
From: Abdul, Hussain (H.) @ 2015-06-16  7:05 UTC (permalink / raw)
  To: gregkh
  Cc: oleg.drokin, andreas.dilger, HPDD-discuss@lists.01.org, devel,
	linux-kernel, Ravindran, Madhusudhanan (M.), Dighe, Niranjan (N.)

From: Abdul Hussain <habdul@visteon.com>

This patch uses memdup_user rather than duplicating its implementation

Signed-off-by: Abdul Hussain <habdul@visteon.com>
---
 drivers/staging/lustre/lustre/llite/dir.c | 32 +++++++++----------------------
 1 file 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)))
-- 
1.9.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-16  7:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-16  7:04 [PATCH] Staging: lustre: Use memdup_user rather than duplicating its implementation Abdul, Hussain (H.)
2015-06-16  7:05 Abdul, Hussain (H.)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®