Skip to content

Commit

Permalink
RDMA/hfi1: Prevent memory leak in sdma_init
Browse files Browse the repository at this point in the history
In sdma_init if rhashtable_init fails the allocated memory for
tmp_sdma_rht should be released.

Fixes: 5a52a7a ("IB/hfi1: NULL pointer dereference when freeing rhashtable")
Link: https://lore.kernel.org/r/20190925144543.10141-1-navid.emamdoost@gmail.com
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Acked-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Navidem authored and jgunthorpe committed Oct 1, 2019
1 parent 390d3fd commit 34b3be1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/infiniband/hw/hfi1/sdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,8 +1526,11 @@ int sdma_init(struct hfi1_devdata *dd, u8 port)
}

ret = rhashtable_init(tmp_sdma_rht, &sdma_rht_params);
if (ret < 0)
if (ret < 0) {
kfree(tmp_sdma_rht);
goto bail;
}

dd->sdma_rht = tmp_sdma_rht;

dd_dev_info(dd, "SDMA num_sdma: %u\n", dd->num_sdma);
Expand Down

0 comments on commit 34b3be1

Please sign in to comment.