Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH] IB/i40iw: Fix error code in i40iw_create_cq()
@ 2017-07-13  7:47 Dan Carpenter
  2017-07-13 14:42 ` Shiraz Saleem
  2017-07-22 17:27 ` Doug Ledford
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2017-07-13  7:47 UTC (permalink / raw)
  To: Faisal Latif
  Cc: Shiraz Saleem, Doug Ledford, Sean Hefty, Hal Rosenstock,
	linux-rdma, kernel-janitors

We accidentally forgot to set the error code if ib_copy_from_udata()
fails.  It means we return ERR_PTR(0) which is NULL and results in a
NULL dereference in the callers.

Fixes: d37498417947 ("i40iw: add files for iwarp interface")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
index 4dbe61ec7a77..91f1631ff32d 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
@@ -1161,8 +1161,10 @@ static struct ib_cq *i40iw_create_cq(struct ib_device *ibdev,
 		memset(&req, 0, sizeof(req));
 		iwcq->user_mode = true;
 		ucontext = to_ucontext(context);
-		if (ib_copy_from_udata(&req, udata, sizeof(struct i40iw_create_cq_req)))
+		if (ib_copy_from_udata(&req, udata, sizeof(struct i40iw_create_cq_req))) {
+			err_code = -EFAULT;
 			goto cq_free_resources;
+		}
 
 		spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags);
 		iwpbl = i40iw_get_pbl((unsigned long)req.user_cq_buffer,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-07-22 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-13  7:47 [PATCH] IB/i40iw: Fix error code in i40iw_create_cq() Dan Carpenter
2017-07-13 14:42 ` Shiraz Saleem
2017-07-22 17:27 ` Doug Ledford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox