You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
RDMA/hfi1: fix potential memory leak in setup_base_ctxt()
[ Upstream commitaa2a1df3a2] setup_base_ctxt() allocates a memory chunk for uctxt->groups with hfi1_alloc_ctxt_rcv_groups(). When init_user_ctxt() fails, uctxt->groups is not released, which will lead to a memory leak. We should release the uctxt->groups with hfi1_free_ctxt_rcv_groups() when init_user_ctxt() fails. Fixes:e87473bc1b("IB/hfi1: Only set fd pointer when base context is completely initialized") Link: https://lore.kernel.org/r/20220711070718.2318320-1-niejianglei2021@163.com Signed-off-by: Jianglei Nie <niejianglei2021@163.com> Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9ade92ddaf
commit
a85c7dd1ed
@@ -1220,8 +1220,10 @@ static int setup_base_ctxt(struct hfi1_filedata *fd,
|
||||
goto done;
|
||||
|
||||
ret = init_user_ctxt(fd, uctxt);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
hfi1_free_ctxt_rcv_groups(uctxt);
|
||||
goto done;
|
||||
}
|
||||
|
||||
user_init(uctxt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user