mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 22:07:35 -04:00
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/20260213-refactor-umem-v1-8-f3be85847922@nvidia.com Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user