From: Dan Carpenter Date: Thu, 13 Jul 2017 07:47:40 +0000 (+0300) Subject: cxgb4: Fix error codes in c4iw_create_cq() X-Git-Tag: v3.2.95~136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce56b921aade5f233c3814c5ff28461133117078;p=thirdparty%2Fkernel%2Fstable.git cxgb4: Fix error codes in c4iw_create_cq() commit 6ebedacbb44602d4dec3348dee5ec31dd9b09521 upstream. If one of these kmalloc() calls fails then we return ERR_PTR(0) which is NULL. It results in a NULL dereference in the callers. Fixes: cfdda9d76436 ("RDMA/cxgb4: Add driver for Chelsio T4 RNIC") Signed-off-by: Dan Carpenter Acked-by: Steve Wise Signed-off-by: Doug Ledford Signed-off-by: Ben Hutchings --- diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c index 3bd6b698c2364..3e5f5763c666c 100644 --- a/drivers/infiniband/hw/cxgb4/cq.c +++ b/drivers/infiniband/hw/cxgb4/cq.c @@ -826,6 +826,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries, goto err2; if (ucontext) { + ret = -ENOMEM; mm = kmalloc(sizeof *mm, GFP_KERNEL); if (!mm) goto err3;