RDMA/core: Reject zero CQE count

All drivers already ensure that the number of CQEs is at least 1.
Add this validation to the core so drivers no longer need to repeat it.
Future patches converting to the .create_user_cq() interface will remove
the per‑driver checks.

Link: https://patch.msgid.link/[email protected]
Signed-off-by: Leon Romanovsky <[email protected]>
This commit is contained in:
Leon Romanovsky committed 2026-02-25 08:15:30 -05:00
1 parent 584ec74748
commit a291758288
4 files changed
+18 -6

No files matched your search

+3
View File
@@ -220,6 +220,9 @@ struct ib_cq *__ib_alloc_cq(struct ib_device *dev, void *private, int nr_cqe,
struct ib_cq *cq;
int ret = -ENOMEM;
if (WARN_ON_ONCE(!nr_cqe))
return ERR_PTR(-EINVAL);
cq = rdma_zalloc_drv_obj(dev, ib_cq);
if (!cq)
return ERR_PTR(ret);
+3
View File
@@ -1032,6 +1032,9 @@ static int create_cq(struct uverbs_attr_bundle *attrs,
if (cmd->comp_vector >= attrs->ufile->device->num_comp_vectors)
return -EINVAL;
if (!cmd->cqe)
return -EINVAL;
obj = (struct ib_ucq_object *)uobj_alloc(UVERBS_OBJECT_CQ, attrs,
&ib_dev);
if (IS_ERR(obj))
@@ -84,12 +84,15 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
ret = uverbs_copy_from(&attr.comp_vector, attrs,
UVERBS_ATTR_CREATE_CQ_COMP_VECTOR);
if (!ret)
ret = uverbs_copy_from(&attr.cqe, attrs,
UVERBS_ATTR_CREATE_CQ_CQE);
if (!ret)
ret = uverbs_copy_from(&user_handle, attrs,
UVERBS_ATTR_CREATE_CQ_USER_HANDLE);
if (ret)
return ret;
ret = uverbs_copy_from(&attr.cqe, attrs, UVERBS_ATTR_CREATE_CQ_CQE);
if (ret || !attr.cqe)
return ret ? : -EINVAL;
ret = uverbs_copy_from(&user_handle, attrs,
UVERBS_ATTR_CREATE_CQ_USER_HANDLE);
if (ret)
return ret;
+3
View File
@@ -2203,6 +2203,9 @@ struct ib_cq *__ib_create_cq(struct ib_device *device,
if (!cq)
return ERR_PTR(-ENOMEM);
if (WARN_ON_ONCE(!cq_attr->cqe))
return ERR_PTR(-EINVAL);
cq->device = device;
cq->comp_handler = comp_handler;
cq->event_handler = event_handler;