Commit 5a7189d5 authored by Mustafa Ismail's avatar Mustafa Ismail Committed by Doug Ledford

i40iw: Fix memory leak in error path of create QP

If i40iw_allocate_dma_mem fails when creating a QP, the
memory allocated for the QP structure using kzalloc is not
freed because iwqp->allocated_buffer is used to free the
memory and it is not setup until later. Fix this by setting
iwqp->allocated_buffer before allocating the dma memory.

Fixes: d3749841 ("i40iw: add files for iwarp interface")
Signed-off-by: default avatarMustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 37da2a03
...@@ -614,6 +614,7 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd, ...@@ -614,6 +614,7 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
iwqp = (struct i40iw_qp *)mem; iwqp = (struct i40iw_qp *)mem;
iwqp->allocated_buffer = mem;
qp = &iwqp->sc_qp; qp = &iwqp->sc_qp;
qp->back_qp = (void *)iwqp; qp->back_qp = (void *)iwqp;
qp->push_idx = I40IW_INVALID_PUSH_PAGE_INDEX; qp->push_idx = I40IW_INVALID_PUSH_PAGE_INDEX;
...@@ -642,7 +643,6 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd, ...@@ -642,7 +643,6 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
goto error; goto error;
} }
iwqp->allocated_buffer = mem;
iwqp->iwdev = iwdev; iwqp->iwdev = iwdev;
iwqp->iwpd = iwpd; iwqp->iwpd = iwpd;
iwqp->ibqp.qp_num = qp_num; iwqp->ibqp.qp_num = qp_num;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment