Blob Blame History Raw
From ef1a51192eb44e7f23d3c5b63a80c0b8b6358660 Mon Sep 17 00:00:00 2001
From: Kamal Heib <kamalheib1@gmail.com>
Date: Thu, 14 Jan 2021 12:34:39 +0200
Subject: [PATCH] bnxt_re: Fix reported error code from create_cq

[ Upstream commit 9a1c8f63344c5b7eb911332501d48fd6b14edde1 ]

Report EINVAL when trying to call bnxt_re_create_cq() with number of CQEs
out of the supported range.

Fixes: fa8dce26b88c ("libbnxt_re: Add support for CQ and QP management")
Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
---
 providers/bnxt_re/verbs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/providers/bnxt_re/verbs.c b/providers/bnxt_re/verbs.c
index 03237e7f8103..20902ab5c020 100644
--- a/providers/bnxt_re/verbs.c
+++ b/providers/bnxt_re/verbs.c
@@ -173,8 +173,10 @@ struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe,
 	struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx);
 	struct bnxt_re_dev *dev = to_bnxt_re_dev(ibvctx->device);
 
-	if (ncqe > dev->max_cq_depth)
+	if (!ncqe || ncqe > dev->max_cq_depth) {
+		errno = EINVAL;
 		return NULL;
+	}
 
 	cq = calloc(1, sizeof(*cq));
 	if (!cq)
-- 
2.25.4