]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit28469761df1d1386e0d35ef73037c7de0d5f7ba1
tree18994f0e4d2c7c5da4a0346b92054aea96c33d21
parent2666473322d5526bf8ee4461e6261cb4fe511ae2
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