public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: replace kzalloc with copy_from_user with memdup_user
@ 2015-03-31 15:10 Dhere, Chaitanya (C.)
  2015-03-31 15:15 ` Julia Lawall
  0 siblings, 1 reply; 7+ messages in thread
From: Dhere, Chaitanya (C.) @ 2015-03-31 15:10 UTC (permalink / raw)
  To: oleg.drokin@intel.com, andreas.dilger@intel.com,
	gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk,
	jinshan.xiong@intel.com, aybuke.147@gmail.com,
	john.hammond@intel.com, Julia.Lawall@lip6.fr
  Cc: HPDD-discuss@lists.01.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org

This patch replaces kzalloc and copy_from_user with memdup_user call
This change was detected with coccinelle tool

Signed-off-by: Chaitanya Dhere <cvijaydh@visteon.com>
---
 drivers/staging/lustre/lustre/llite/file.c |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 85e74d1..85b5567 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -2368,14 +2368,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))) {
-			OBD_FREE_PTR(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);
 
-- 
1.7.9.5

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

end of thread, other threads:[~2015-04-03 19:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-31 15:10 [PATCH] staging: lustre: replace kzalloc with copy_from_user with memdup_user Dhere, Chaitanya (C.)
2015-03-31 15:15 ` Julia Lawall
2015-03-31 15:57   ` gregkh
2015-03-31 22:45     ` Drokin, Oleg
2015-04-02 10:18       ` Julia Lawall
2015-04-03 18:56         ` Drokin, Oleg
2015-04-03 19:51           ` Julia Lawall

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