diff options
author | Zhipeng Lu <alexious@zju.edu.cn> | 2024-01-12 16:55:23 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-03-01 13:16:49 +0100 |
commit | 3fa240bb6b2dbb3e7a3ee1440a4889cbb6207eb7 (patch) | |
tree | b3471e3f845ff365fbd6c989bc49ea58cedf50ed | |
parent | 8affdbb3e2ef6b6a3a467b87dc336dc601dc2ed9 (diff) | |
download | linux-stable-3fa240bb6b2dbb3e7a3ee1440a4889cbb6207eb7.tar.gz linux-stable-3fa240bb6b2dbb3e7a3ee1440a4889cbb6207eb7.tar.bz2 linux-stable-3fa240bb6b2dbb3e7a3ee1440a4889cbb6207eb7.zip |
IB/hfi1: Fix a memleak in init_credit_return
[ Upstream commit 809aa64ebff51eb170ee31a95f83b2d21efa32e2 ]
When dma_alloc_coherent fails to allocate dd->cr_base[i].va,
init_credit_return should deallocate dd->cr_base and
dd->cr_base[i] that allocated before. Or those resources
would be never freed and a memleak is triggered.
Fixes: 7724105686e7 ("IB/hfi1: add driver files")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Link: https://lore.kernel.org/r/20240112085523.3731720-1-alexious@zju.edu.cn
Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/infiniband/hw/hfi1/pio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c index 60eb3a64518f..969004258692 100644 --- a/drivers/infiniband/hw/hfi1/pio.c +++ b/drivers/infiniband/hw/hfi1/pio.c @@ -2131,7 +2131,7 @@ int init_credit_return(struct hfi1_devdata *dd) "Unable to allocate credit return DMA range for NUMA %d\n", i); ret = -ENOMEM; - goto done; + goto free_cr_base; } } set_dev_node(&dd->pcidev->dev, dd->node); @@ -2139,6 +2139,10 @@ int init_credit_return(struct hfi1_devdata *dd) ret = 0; done: return ret; + +free_cr_base: + free_credit_return(dd); + goto done; } void free_credit_return(struct hfi1_devdata *dd) |