Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1467188
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation |
| Date | 2016-08-21 19:50 +0200 |
| Message-ID | <s8F2F-3mZ-7@gated-at.bofh.it> (permalink) |
| References | <qEuGl-43C-5@gated-at.bofh.it> <s8ESZ-3jP-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Sun, 21 Aug 2016 18:45:22 +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> --- include/rdma/ib_verbs.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 6f667dd..033610b 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2205,16 +2205,11 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata, if (len > USHRT_MAX) return false; - buf = kmalloc(len, GFP_KERNEL); - if (!buf) + buf = memdup_user(p, len); + if (IS_ERR(buf)) return false; - if (copy_from_user(buf, p, len)) - goto free; - ret = !memchr_inv(buf, 0, len); - -free: kfree(buf); return ret; } -- 2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 19:40 +0200
[PATCH 2/2] IB/core: Delete an unnecessary initialisation in ib_is_udata_cleared() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 19:50 +0200
[PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 19:50 +0200
Re: [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() Joe Perches <joe@perches.com> - 2016-08-21 20:10 +0200
Re: IB/core: Fine-tuning for ib_is_udata_cleared() Joe Perches <joe@perches.com> - 2016-08-21 22:00 +0200
Re: IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 22:20 +0200
Re: IB/core: Fine-tuning for ib_is_udata_cleared() Yann Droneaud <ydroneaud@opteya.com> - 2016-08-22 11:50 +0200
[PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-22 18:40 +0200
Re: [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation Doug Ledford <dledford@redhat.com> - 2016-08-23 18:50 +0200
Re: IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-21 22:00 +0200
csiph-web