mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-21 02:30:51 -05:00
IB/hfi1: Fix a memleak in init_credit_return
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: 7724105686 ("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>
This commit is contained in:
committed by
Leon Romanovsky
parent
6613476e22
commit
809aa64ebf
@@ -2086,7 +2086,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);
|
||||
@@ -2094,6 +2094,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)
|
||||
|
||||
Reference in New Issue
Block a user