[PATCH 09/10] RDMA/bnxt_re: Use ib_respond_udata()

Jason Gunthorpe
2026-02-06T01:45:53Z

All the calls to ib_copy_to_udata() can use this helper safely.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 6ea03e1f6c23dd..9d1c31bb994218 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -748,7 +748,7 @@ int bnxt_re_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)

pd->pd_db_mmap = &entry->rdma_entry;

- rc = ib_copy_to_udata(udata, &resp, min(sizeof(resp), udata->outlen));
+ rc = ib_respond_udata(udata, resp);
if (rc) {
rdma_user_mmap_entry_remove(pd->pd_db_mmap);
rc = -EFAULT;
@@ -1705,7 +1705,7 @@ int bnxt_re_create_qp(struct ib_qp *ib_qp, struct ib_qp_init_attr *qp_init_attr,

resp.qpid = qp->qplib_qp.id;
resp.rsvd = 0;
- rc = ib_copy_to_udata(udata, &resp, sizeof(resp));
+ rc = ib_respond_udata(udata, resp);
if (rc) {
ibdev_err(&rdev->ibdev, "Failed to copy QP udata");
goto qp_destroy;
@@ -1966,7 +1966,7 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
}
resp.comp_mask |= BNXT_RE_SRQ_TOGGLE_PAGE_SUPPORT;
}
- rc = ib_copy_to_udata(udata, &resp, sizeof(resp));
+ rc = ib_respond_udata(udata, resp);
if (rc) {
ibdev_err(&rdev->ibdev, "SRQ copy to udata failed!");
bnxt_qplib_destroy_srq(&rdev->qplib_res,
@@ -3248,7 +3248,7 @@ int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
resp.tail = cq->qplib_cq.hwq.cons;
resp.phase = cq->qplib_cq.period;
resp.rsvd = 0;
- rc = ib_copy_to_udata(udata, &resp, min(sizeof(resp), udata->outlen));
+ rc = ib_respond_udata(udata, resp);
if (rc) {
ibdev_err(&rdev->ibdev, "Failed to copy CQ udata");
bnxt_qplib_destroy_cq(&rdev->qplib_res, &cq->qplib_cq);
@@ -4449,7 +4449,7 @@ int bnxt_re_alloc_ucontext(struct ib_ucontext *ctx, struct ib_udata *udata)
}
}

- rc = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp)));
+ rc = ib_respond_udata(udata, resp);
if (rc) {
ibdev_err(ibdev, "Failed to copy user context");
rc = -EFAULT;
--
2.43.0