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)
committerLeon Romanovsky <leonro@nvidia.com>
Tue, 19 Jul 2022 05:21:29 +0000 (08:21 +0300)
commitaa2a1df3a2c85f855af7d54466ac10bd48645d63
treed863fec02e827c485a56776ff88ce9119276c2c3
parent03905ac2852c577c9d863ed92fa6cc8ffabb2c7b
RDMA/hfi1: fix potential memory leak in setup_base_ctxt()

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