Skip to contentSkip to conversation

RDMA/efa: Remove redundant udata check from alloc ucontext response

PATCH Applied Gal Pressman 2 participants 2 messages Aug 18, 2020 – Aug 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/efa: Remove redundant udata check from alloc ucontext response

The alloc ucontext flow is always called with a valid udata, there's no need to test whether it's NULL.

While at it, the 'udata->outlen' check is removed as well as we copy the minimum between the size of the response and outlen, so in case of zero outlen, zero bytes will be copied.

---
 drivers/infiniband/hw/efa/efa_verbs.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/infiniband/hw/efa/efa_verbs.c +4 -6
index fda175836fb6..b53acd238d36 100644
@@ -1568,12 +1568,10 @@ int efa_alloc_ucontext(struct ib_ucontext *ibucontext, struct ib_udata *udata)
 	resp.max_tx_batch = dev->dev_attr.max_tx_batch;
 	resp.min_sq_wr = dev->dev_attr.min_sq_depth;
 
-	if (udata && udata->outlen) {
-		err = ib_copy_to_udata(udata, &resp,
-				       min(sizeof(resp), udata->outlen));
-		if (err)
-			goto err_dealloc_uar;
-	}
+	err = ib_copy_to_udata(udata, &resp,
+			       min(sizeof(resp), udata->outlen));
+	if (err)
+		goto err_dealloc_uar;
 
 	return 0;
 
Signature · 1 line
2.28.0
maintainer Applied
#1 lore raw
Quoted 7 lines · Gal Pressman

The alloc ucontext flow is always called with a valid udata, there's no need to test whether it's NULL.

While at it, the 'udata->outlen' check is removed as well as we copy the minimum between the size of the response and outlen, so in case of zero outlen, zero bytes will be copied.

Quoted 6 lines
---
 drivers/infiniband/hw/efa/efa_verbs.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Applied to for-next, thanks

Jason