Skip to contentSkip to conversation

RDMA/mlx5: Fix udata response upon SRQ creation

PATCH In review Leon Romanovsky 2 participants 2 messages Apr 6, 2020 – Apr 14, 2020

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

PATCH 1/1 RDMA/mlx5: Fix udata response upon SRQ creation

From: Yishai Hadas <[email protected]>

Fix udata response upon SRQ creation to use the UAPI structure (i.e. mlx5_ib_create_srq_resp).

Fixes e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
---
 drivers/infiniband/hw/mlx5/srq.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/srq.c +7 -2
index b1a8a9175040..3c2a84c362bb 100644
@@ -310,12 +310,17 @@ int mlx5_ib_create_srq(struct ib_srq *ib_srq,
 	srq->msrq.event = mlx5_ib_srq_event;
 	srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn;
 
-	if (udata)
-		if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof(__u32))) {
+	if (udata) {
+		struct mlx5_ib_create_srq_resp resp = {};
+
+		resp.srqn = srq->msrq.srqn;
+		if (ib_copy_to_udata(udata, &resp, min(udata->outlen,
+				     sizeof(resp)))) {
 			mlx5_ib_dbg(dev, "copy to user failed\n");
 			err = -EFAULT;
 			goto err_core;
 		}
+	}
 
 	init_attr->attr.max_wr = srq->msrq.max - 1;
 

--
2.25.1

#1 lore raw
Quoted 11 lines · Leon Romanovsky

From: Yishai Hadas <[email protected]>

Fix udata response upon SRQ creation to use the UAPI structure (i.e. mlx5_ib_create_srq_resp).

Fixes e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
---
 drivers/infiniband/hw/mlx5/srq.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

This isn't really a -rc issue, applied to for-next, thanks

Jason