Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1465066
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/5] block-cciss: Use memdup_user() rather than duplicating its implementation |
| Date | 2016-08-18 12:00 +0200 |
| Message-ID | <s7shc-6qu-11@gated-at.bofh.it> (permalink) |
| References | <qEuGl-43C-5@gated-at.bofh.it> <s7shc-6qu-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 17 Aug 2016 22:10:29 +0200
* Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.
This issue was detected by using the Coccinelle software.
* Return directly if this copy operation failed.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
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 db9d6bb..e044342 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1587,15 +1587,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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/5] block-cciss: Fine-tuning for two function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:00 +0200 [PATCH 1/5] block-cciss: Use memdup_user() rather than duplicating its implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:00 +0200 [PATCH 2/5] block-cciss: Less function calls in cciss_bigpassthru() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:00 +0200 [PATCH 3/5] block-cciss: Delete unnecessary initialisations in cciss_bigpassthru() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:10 +0200 [PATCH 4/5] block-cciss: Move an assignment for the variable "sg_used" in cciss_bigpassthru() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:10 +0200 [PATCH 5/5] block-cciss: Replace three kzalloc() calls by kcalloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-18 12:10 +0200
csiph-web