summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2016-08-22 18:23:24 +0200
committerDoug Ledford <dledford@redhat.com>2016-08-23 12:40:13 -0400
commit92d27ae6b3bb3491c1685fb3ca7ae1b26d81bdf4 (patch)
treee337a55475d8899a35c3d5bc76d00b808d28a21e /include
parent48ef5865d08fa0a36d786f2f8e12c6194d27538b (diff)
downloadlwn-92d27ae6b3bb3491c1685fb3ca7ae1b26d81bdf4.tar.gz
lwn-92d27ae6b3bb3491c1685fb3ca7ae1b26d81bdf4.zip
IB/core: Use memdup_user() rather than duplicating its implementation
* Reuse existing functionality from memdup_user() instead of keeping duplicate source code. This issue was detected by using the Coccinelle software. * The local variable "ret" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/rdma/ib_verbs.h11
1 files changed, 3 insertions, 8 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 8e90dd28bb75..e1f96737c2a1 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2115,22 +2115,17 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
size_t len)
{
const void __user *p = udata->inbuf + offset;
- bool ret = false;
+ bool ret;
u8 *buf;
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;
}