From: Geliang Tang <geliangtang@gmail.com>
To: Don Brace <don.brace@microsemi.com>
Cc: Geliang Tang <geliangtang@gmail.com>,
esc.storagedev@microsemi.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] cciss: use memdup_user
Date: Sat, 29 Apr 2017 09:45:11 +0800 [thread overview]
Message-ID: <4db2a0ba17dc68d7bcfbd7d47b0eb22ad9a220c2.1493381463.git.geliangtang@gmail.com> (raw)
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
next reply other threads:[~2017-04-29 1:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-29 1:45 Geliang Tang [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4db2a0ba17dc68d7bcfbd7d47b0eb22ad9a220c2.1493381463.git.geliangtang@gmail.com \
--to=geliangtang@gmail.com \
--cc=don.brace@microsemi.com \
--cc=esc.storagedev@microsemi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®