Skip to content

Commit 34b3be1

Browse files
Navidemjgunthorpe
authored andcommitted
RDMA/hfi1: Prevent memory leak in sdma_init
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>
1 parent 390d3fd commit 34b3be1

File tree

1 file changed

+4
-1
lines changed
  • drivers/infiniband/hw/hfi1

1 file changed

+4
-1
lines changed

Diff for: drivers/infiniband/hw/hfi1/sdma.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1526,8 +1526,11 @@ int sdma_init(struct hfi1_devdata *dd, u8 port)
15261526
}
15271527

15281528
ret = rhashtable_init(tmp_sdma_rht, &sdma_rht_params);
1529-
if (ret < 0)
1529+
if (ret < 0) {
1530+
kfree(tmp_sdma_rht);
15301531
goto bail;
1532+
}
1533+
15311534
dd->sdma_rht = tmp_sdma_rht;
15321535

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

0 commit comments

Comments
 (0)