[PATCH 07/10] RDMA/bnxt_re: Add compatibility checks to the uapi path for no data

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

If drivers ever want to go from an empty drvdata to something with them
they need to have called ib_is_udata_in_empty(). Add the missing calls to
all the system calls that don't have req structures.

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

diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 2942ff44f6a547..485785fad1df63 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -187,6 +187,9 @@ int bnxt_re_query_device(struct ib_device *ibdev,
struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr;

+ if (!ib_is_udata_in_empty(udata))
+ return -EOPNOTSUPP;
+
memset(ib_attr, 0, sizeof(*ib_attr));
memcpy(&ib_attr->fw_ver, dev_attr->fw_ver,
min(sizeof(dev_attr->fw_ver),
@@ -676,6 +679,9 @@ int bnxt_re_dealloc_pd(struct ib_pd *ib_pd, struct ib_udata *udata)
struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
struct bnxt_re_dev *rdev = pd->rdev;

+ if (!ib_is_udata_in_empty(udata))
+ return -EOPNOTSUPP;
+
if (udata) {
rdma_user_mmap_entry_remove(pd->pd_db_mmap);
pd->pd_db_mmap = NULL;
@@ -703,6 +709,9 @@ int bnxt_re_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
u32 active_pds;
int rc = 0;

+ if (!ib_is_udata_in_empty(udata))
+ return -EOPNOTSUPP;
+
pd->rdev = rdev;
if (bnxt_qplib_alloc_pd(&rdev->qplib_res, &pd->qplib_pd)) {
ibdev_err(&rdev->ibdev, "Failed to allocate HW PD");
@@ -817,6 +826,9 @@ int bnxt_re_create_ah(struct ib_ah *ib_ah, struct rdma_ah_init_attr *init_attr,
u8 nw_type;
int rc;

+ if (!ib_is_udata_in_empty(udata))
+ return -EOPNOTSUPP;
+
if (!(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH)) {
ibdev_err(&rdev->ibdev, "Failed to alloc AH: GRH not set");
return -EINVAL;
@@ -978,6 +990,9 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
unsigned int flags;
int rc;

+ if (!ib_is_udata_in_empty(udata))
+ return -EOPNOTSUPP;
+
bnxt_re_debug_rem_qpinfo(rdev, qp);

bnxt_qplib_flush_cqn_wq(&qp->qplib_qp);
@@ -1828,6 +1843,9 @@ int bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata)
struct bnxt_re_dev *rdev = srq->rdev;
struct bnxt_qplib_srq *qplib_srq = &srq->qplib_srq;

+ if (!ib_is_udata_in_empty(udata))
+ return -EOPNOTSUPP;
+
if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT) {
free_page((unsigned long)srq->uctx_srq_page);
hash_del(&srq->hash_entry);
@@ -1977,6 +1995,9 @@ int bnxt_re_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr,
ib_srq);
struct bnxt_re_dev *rdev = srq->rdev;

+ if (!ib_is_udata_in_empty(udata))
+ return -EOPNOTSUPP;
+
switch (srq_attr_mask) {
case IB_SRQ_MAX_WR:
/* SRQ resize is not supported */
@@ -2093,6 +2114,9 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
unsigned int flags;
u8 nw_type;

+ if (!ib_is_udata_in_empty(udata))
+ return -EOPNOTSUPP;
+
if (qp_attr_mask & ~IB_QP_ATTR_STANDARD_BITS)
return -EOPNOTSUPP;

@@ -3111,6 +3135,9 @@ int bnxt_re_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
nq = cq->qplib_cq.nq;
cctx = rdev->chip_ctx;

+ if (!ib_is_udata_in_empty(udata))
+ return -EOPNOTSUPP;
+
if (cctx->modes.toggle_bits & BNXT_QPLIB_CQ_TOGGLE_BIT) {
free_page((unsigned long)cq->uctx_cq_page);
hash_del(&cq->hash_entry);
@@ -4058,6 +4085,9 @@ int bnxt_re_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata)
struct bnxt_re_dev *rdev = mr->rdev;
int rc;

+ if (!ib_is_udata_in_empty(udata))
+ return -EOPNOTSUPP;
+
rc = bnxt_qplib_free_mrw(&rdev->qplib_res, &mr->qplib_mr);
if (rc) {
ibdev_err(&rdev->ibdev, "Dereg MR failed: %#x\n", rc);
@@ -4166,6 +4196,9 @@ struct ib_mw *bnxt_re_alloc_mw(struct ib_pd *ib_pd, enum ib_mw_type type,
u32 active_mws;
int rc;

+ if (!ib_is_udata_in_empty(udata))
+ return ERR_PTR(-EOPNOTSUPP);
+
mw = kzalloc(sizeof(*mw), GFP_KERNEL);
if (!mw)
return ERR_PTR(-ENOMEM);
@@ -4294,6 +4327,9 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,
struct ib_umem *umem;
struct ib_mr *ib_mr;

+ if (!ib_is_udata_in_empty(udata))
+ return ERR_PTR(-EOPNOTSUPP);
+
if (dmah)
return ERR_PTR(-EOPNOTSUPP);

@@ -4474,6 +4510,9 @@ struct ib_flow *bnxt_re_create_flow(struct ib_qp *ib_qp,
struct bnxt_re_flow *flow;
int rc;

+ if (!ib_is_udata_in_empty(udata))
+ return ERR_PTR(-EOPNOTSUPP);
+
if (attr->type != IB_FLOW_ATTR_SNIFFER ||
!rdev->rcfw.roce_mirror)
return ERR_PTR(-EOPNOTSUPP);
--
2.43.0