RDMA/irdma: Validate number of CQ entries on create CQ
authorSindhu Devale <sindhu.devale@intel.com>
Thu, 16 Sep 2021 19:12:20 +0000 (14:12 -0500)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 20 Sep 2021 17:13:23 +0000 (14:13 -0300)
Add lower bound check for CQ entries at creation time.

Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
Link: https://lore.kernel.org/r/20210916191222.824-3-shiraz.saleem@intel.com
Signed-off-by: Sindhu Devale <sindhu.devale@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/irdma/verbs.c

index 829ddfa..23c4748 100644 (file)
@@ -2034,7 +2034,7 @@ static int irdma_create_cq(struct ib_cq *ibcq,
                /* Kmode allocations */
                int rsize;
 
-               if (entries > rf->max_cqe) {
+               if (entries < 1 || entries > rf->max_cqe) {
                        err_code = -EINVAL;
                        goto cq_free_rsrc;
                }