Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1466075
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation |
| Date | 2016-08-19 09:10 +0200 |
| Message-ID | <s7M6e-2to-11@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 19 Aug 2016 08:50:23 +0200
Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/qib/qib_fs.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c
index fcdf3791..910f0d9 100644
--- a/drivers/infiniband/hw/qib/qib_fs.c
+++ b/drivers/infiniband/hw/qib/qib_fs.c
@@ -338,17 +338,12 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
goto bail;
}
- tmp = kmalloc(count, GFP_KERNEL);
- if (!tmp) {
- ret = -ENOMEM;
+ tmp = memdup_user(buf, count);
+ if (IS_ERR(tmp)) {
+ ret = PTR_ERR(tmp);
goto bail;
}
- if (copy_from_user(tmp, buf, count)) {
- ret = -EFAULT;
- goto bail_tmp;
- }
-
dd = private2dd(file);
if (qib_eeprom_write(dd, pos, tmp, count)) {
ret = -ENXIO;
--
2.9.3
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-19 09:10 +0200
RE: [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation "Marciniszyn, Mike" <mike.marciniszyn@intel.com> - 2016-08-19 17:40 +0200
RE: [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation "Marciniszyn, Mike" <mike.marciniszyn@intel.com> - 2016-08-19 17:50 +0200
Re: [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation Leon Romanovsky <leon@kernel.org> - 2016-08-19 17:50 +0200
Re: [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation Leon Romanovsky <leon@kernel.org> - 2016-08-19 18:00 +0200
Re: [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation Doug Ledford <dledford@redhat.com> - 2016-08-23 18:50 +0200
Re: [PATCH] IB/qib: Use memdup_user() rather than duplicating its implementation Leon Romanovsky <leon@kernel.org> - 2016-08-19 17:40 +0200
csiph-web