i40iw: Fix memory leak in error path of create QP
authorMustafa Ismail <mustafa.ismail@intel.com>
Mon, 7 May 2018 17:52:17 +0000 (12:52 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Dec 2018 08:42:58 +0000 (09:42 +0100)
commit31a673709a853cf28ca4a1bb88e15bf4c0bf099f
tree4514b5cdfbec39b80c1466b43f0ce56eb07b4139
parent9d9cd2bcfc5298109bd90c52f239011337147812
i40iw: Fix memory leak in error path of create QP

commit 5a7189d529cd146cd5838af97b32fcac4122b471 upstream.

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: d37498417947 ("i40iw: add files for iwarp interface")
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/i40iw/i40iw_verbs.c