Skip to contentSkip to conversation

IB/hfi1: prevent memory leak in sdma_init

PATCH New Navid Emamdoost 1 participant 1 message Oct 2, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 1/1 IB/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 5a52a7acf7e2 ("IB/hfi1: NULL pointer dereference when freeing rhashtable")

---
Changes in v2:
-- added Fixes tag.

---
 drivers/infiniband/hw/hfi1/sdma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/sdma.c +4 -1
index 2395fd4233a7..2ed7bfd5feea 100644
@@ -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);
Signature · 1 line
2.17.1