Skip to contentSkip to conversation

staging: lustre: llite: kzalloc/copy_to_user to memdup_user

PATCH New Tobin C Harding 1 participant 1 message May 23, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: lustre: llite: kzalloc/copy_to_user to memdup_user

kzalloc call followed by copy_to_user can be replaced by call to memdup_user.

---
 drivers/staging/lustre/lustre/llite/dir.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/staging/lustre/lustre/llite/dir.c +3 -9
index 4b00d1a..85c50e0 100644
@@ -1076,17 +1076,11 @@ static int copy_and_ioctl(int cmd, struct obd_export *exp,
 	void *copy;
 	int rc;
 
-	copy = kzalloc(size, GFP_NOFS);
-	if (!copy)
-		return -ENOMEM;
-
-	if (copy_from_user(copy, data, size)) {
-		rc = -EFAULT;
-		goto out;
-	}
+	copy = memdup_user(data, size);
+	if (IS_ERR(copy))
+		return PTR_ERR(copy);
 
 	rc = obd_iocontrol(cmd, exp, size, copy, NULL);
-out:
 	kfree(copy);
 
 	return rc;
Signature · 1 line
2.8.2