RDMA/mlx5: Fix UMR cleanup on error flow of driver init
authorMaor Gottlieb <maorg@nvidia.com>
Mon, 29 Aug 2022 09:02:29 +0000 (12:02 +0300)
committerLeon Romanovsky <leon@kernel.org>
Mon, 5 Sep 2022 11:49:57 +0000 (14:49 +0300)
commit9b7d4be967f16f79a2283b2338709fcc750313ee
treeddc47367735b776d38e9b8597a21eb6ed01379cc
parent74b30b3ad5cec95d2647e796d10137438a098bc1
RDMA/mlx5: Fix UMR cleanup on error flow of driver init

The cited commit removed from the cleanup flow of umr the checks
if the resources were created. This could lead to null-ptr-deref
in case that we had failure in mlx5_ib_stage_ib_reg_init stage.

Fix it by adding new state to the umr that can say if the resources
were created or not and check it in the umr cleanup flow before
destroying the resources.

Fixes: 04876c12c19e ("RDMA/mlx5: Move init and cleanup of UMR to umr.c")
Reviewed-by: Michael Guralnik <michaelgur@nvidia.com>
Signed-off-by: Maor Gottlieb <maorg@nvidia.com>
Link: https://lore.kernel.org/r/4cfa61386cf202e9ce330e8d228ce3b25a36326e.1661763459.git.leonro@nvidia.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/mlx5/mlx5_ib.h
drivers/infiniband/hw/mlx5/umr.c