[PATCH rdma-next v1] RDMA/uverbs: Optimize clearing of extra bytes in response

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Leon Romanovsky <leonro@xxxxxxxxxxxx>

Clear extra bytes in response in batch manner instead
of doing it per-byte.

Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
Changelog v0->v1:
 * Change coding style per Jason's request,
---
 drivers/infiniband/core/uverbs_cmd.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 50c512b5a76d..4cd00691b7d9 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;
--
2.19.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux