]> git.baikalelectronics.ru Git - kernel.git/commit
RDMA/hfi1: fix potential memory leak in setup_base_ctxt()
authorJianglei Nie <niejianglei2021@163.com>
Mon, 11 Jul 2022 07:07:18 +0000 (15:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:17:57 +0000 (11:17 +0200)
commit39d03057945e33f96baa63f31c2c6de591896b4f
tree2501f6848343e8e695d650d0244e7aa028f7d9b0
parentc75004b7a3a9006893bf04010ab7eabcef99505c
RDMA/hfi1: fix potential memory leak in setup_base_ctxt()

[ Upstream commit e9429b98caa399a2dba2fcce9567c3e27d73adca ]

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: e689e148b11d ("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>
drivers/infiniband/hw/hfi1/file_ops.c