Blame SOURCES/0001-bnxt_re-Fix-reported-error-code-from-create_cq.patch

3bcb62
From ef1a51192eb44e7f23d3c5b63a80c0b8b6358660 Mon Sep 17 00:00:00 2001
3bcb62
From: Kamal Heib <kamalheib1@gmail.com>
3bcb62
Date: Thu, 14 Jan 2021 12:34:39 +0200
3bcb62
Subject: [PATCH] bnxt_re: Fix reported error code from create_cq
3bcb62
3bcb62
[ Upstream commit 9a1c8f63344c5b7eb911332501d48fd6b14edde1 ]
3bcb62
3bcb62
Report EINVAL when trying to call bnxt_re_create_cq() with number of CQEs
3bcb62
out of the supported range.
3bcb62
3bcb62
Fixes: fa8dce26b88c ("libbnxt_re: Add support for CQ and QP management")
3bcb62
Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
3bcb62
Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
3bcb62
---
3bcb62
 providers/bnxt_re/verbs.c | 4 +++-
3bcb62
 1 file changed, 3 insertions(+), 1 deletion(-)
3bcb62
3bcb62
diff --git a/providers/bnxt_re/verbs.c b/providers/bnxt_re/verbs.c
3bcb62
index 03237e7f8103..20902ab5c020 100644
3bcb62
--- a/providers/bnxt_re/verbs.c
3bcb62
+++ b/providers/bnxt_re/verbs.c
3bcb62
@@ -173,8 +173,10 @@ struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe,
3bcb62
 	struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx);
3bcb62
 	struct bnxt_re_dev *dev = to_bnxt_re_dev(ibvctx->device);
3bcb62
 
3bcb62
-	if (ncqe > dev->max_cq_depth)
3bcb62
+	if (!ncqe || ncqe > dev->max_cq_depth) {
3bcb62
+		errno = EINVAL;
3bcb62
 		return NULL;
3bcb62
+	}
3bcb62
 
3bcb62
 	cq = calloc(1, sizeof(*cq));
3bcb62
 	if (!cq)
3bcb62
-- 
3bcb62
2.25.4
3bcb62