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>
This commit is contained in:
parent
a276a4d93b
commit
9435ef4cae
@ -58,19 +58,21 @@
|
|||||||
static int uverbs_response(struct uverbs_attr_bundle *attrs, const void *resp,
|
static int uverbs_response(struct uverbs_attr_bundle *attrs, const void *resp,
|
||||||
size_t resp_len)
|
size_t resp_len)
|
||||||
{
|
{
|
||||||
u8 __user *cur = attrs->ucore.outbuf + resp_len;
|
|
||||||
u8 __user *end = attrs->ucore.outbuf + attrs->ucore.outlen;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (copy_to_user(attrs->ucore.outbuf, resp,
|
if (copy_to_user(attrs->ucore.outbuf, resp,
|
||||||
min(attrs->ucore.outlen, resp_len)))
|
min(attrs->ucore.outlen, resp_len)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
/* Zero fill any extra memory that user space might have provided */
|
if (resp_len < attrs->ucore.outlen) {
|
||||||
for (; cur < end; cur++) {
|
/*
|
||||||
ret = put_user(0, cur);
|
* 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)
|
if (ret)
|
||||||
return ret;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user