IB/hfi1: Fix a potential memory leak in hfi1_create_ctxts()
authorJianxin Xiong <jianxin.xiong@intel.com>
Mon, 17 Oct 2016 11:19:41 +0000 (04:19 -0700)
committerDoug Ledford <dledford@redhat.com>
Tue, 15 Nov 2016 21:16:42 +0000 (16:16 -0500)
commit4dfe7cceb2bfd98783b4966d7c881a7552932d31
tree18994f0e4d2c7c5da4a0346b92054aea96c33d21
parent83fb4af6800deb4f3d19b297df6148cda5c016de
IB/hfi1: Fix a potential memory leak in hfi1_create_ctxts()

In the function hfi1_create_ctxts the array "dd->rcd" is allocated and
then populated with allocated resources in a loop. Previously, if
error happened during the loop, only resource allocated in the current
iteration would be freed. The array itself would then be freed, leaving
the resources that were allocated in previous iterations and referenced
by the array elements in limbo.

This patch makes sure all allocated resources are freed before freeing
the array "dd->rcd". Also the resource allocation now takes account of
the numa node the device is attached to.

Reviewed-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Jianxin Xiong <jianxin.xiong@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/init.c