aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/uverbs_cmd.c
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2018-12-11 11:41:05 +0200
committerJason Gunthorpe <jgg@mellanox.com>2018-12-11 14:38:17 -0700
commit9435ef4caeea0a1141e461f9ee6f91b173867c05 (patch)
tree2d1b1eccf7ec50027772a1bb2156a5baff4af720 /drivers/infiniband/core/uverbs_cmd.c
parentRDMA/vmw_pvrdma: Use atomic memory allocation in create AH (diff)
downloadlinux-dev-9435ef4caeea0a1141e461f9ee6f91b173867c05.tar.xz
linux-dev-9435ef4caeea0a1141e461f9ee6f91b173867c05.zip
RDMA/uverbs: Optimize clearing of extra bytes in response
Clear extra bytes in response in batch manner instead of doing it per-byte. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to '')
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index b70749542471..7f10eade7653 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -58,19 +58,21 @@
static int uverbs_response(struct uverbs_attr_bundle *attrs, const void *resp,
size_t resp_len)
{
- u8 __user *cur = attrs->ucore.outbuf + resp_len;
- u8 __user *end = attrs->ucore.outbuf + attrs->ucore.outlen;
int ret;
if (copy_to_user(attrs->ucore.outbuf, resp,
min(attrs->ucore.outlen, resp_len)))
return -EFAULT;
- /* Zero fill any extra memory that user space might have provided */
- for (; cur < end; cur++) {
- ret = put_user(0, cur);
+ if (resp_len < attrs->ucore.outlen) {
+ /*
+ * Zero fill any extra memory that user
+ * space might have provided.
+ */
+ ret = clear_user(attrs->ucore.outbuf + resp_len,
+ attrs->ucore.outlen - resp_len);
if (ret)
- return ret;
+ return -EFAULT;
}
return 0;