linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cciss: use memdup_user
@ 2017-04-29  1:45 Geliang Tang
  2017-04-29  1:45 ` [PATCH] floppy: " Geliang Tang
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Geliang Tang @ 2017-04-29  1:45 UTC (permalink / raw)
  To: Don Brace; +Cc: Geliang Tang, esc.storagedev, linux-scsi, linux-kernel

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/block/cciss.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index cd37550..40ee715 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1596,15 +1596,9 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 		return -EINVAL;
 	if (!capable(CAP_SYS_RAWIO))
 		return -EPERM;
-	ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
-	if (!ioc) {
-		status = -ENOMEM;
-		goto cleanup1;
-	}
-	if (copy_from_user(ioc, argp, sizeof(*ioc))) {
-		status = -EFAULT;
-		goto cleanup1;
-	}
+	ioc = memdup_user(argp, sizeof(*ioc));
+	if (IS_ERR(ioc))
+		return PTR_ERR(ioc);
 	if ((ioc->buf_size < 1) &&
 	    (ioc->Request.Type.Direction != XFER_NONE)) {
 		status = -EINVAL;
-- 
2.9.3

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

end of thread, other threads:[~2017-07-27 12:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-29  1:45 [PATCH] cciss: use memdup_user Geliang Tang
2017-04-29  1:45 ` [PATCH] floppy: " Geliang Tang
2017-04-29  1:45 ` [PATCH] powerpc/nvram: " Geliang Tang
2017-06-28  0:08   ` Kees Cook
2017-04-29  1:45 ` [PATCH] powerpc/powernv: " Geliang Tang
2017-07-27 12:37   ` Michael Ellerman
2017-04-29  1:45 ` [PATCH] powerpc/pseries: use memdup_user_nul Geliang Tang
2017-07-27 12:37   ` Michael Ellerman
2017-04-29  1:45 ` [PATCH] pstore: use memdup_user Geliang Tang
2017-06-28  0:07   ` Kees Cook
2017-04-29  1:45 ` [PATCH] skd_main: " Geliang Tang
2017-04-29  1:45 ` [PATCH] staging: comedi: " Geliang Tang
2017-04-29  1:53   ` Joe Perches
2017-04-29  5:17     ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).