From 5dee0eaa3a3c1f6b8e960038384e16ae730d201e Mon Sep 17 00:00:00 2001 From: Kamal Heib Date: Thu, 24 Dec 2020 16:11:16 +0200 Subject: [PATCH] cxgb4: Fix reported error code from create_cq [ Upstream commit 8f85e04863e379d798c88a68eee5e34341961eff ] Report EINVAL when trying to call c4iw_create_cq() with number of CQEs out of the supported range. Fixes: d6e6ae69be5e ("Add libcxgb4 files.") Signed-off-by: Kamal Heib Signed-off-by: Nicolas Morey-Chaisemartin --- providers/cxgb4/verbs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/providers/cxgb4/verbs.c b/providers/cxgb4/verbs.c index 32bae6906a15..d0e366f0fca4 100644 --- a/providers/cxgb4/verbs.c +++ b/providers/cxgb4/verbs.c @@ -171,6 +171,11 @@ struct ibv_cq *c4iw_create_cq(struct ibv_context *context, int cqe, struct c4iw_dev *dev = to_c4iw_dev(context->device); int ret; + if (!cqe || cqe > T4_MAX_CQ_DEPTH) { + errno = EINVAL; + return NULL; + } + chp = calloc(1, sizeof *chp); if (!chp) { return NULL; -- 2.25.4