RDMA/irdma: Fix a user-after-free in add_pble_prm
authorShiraz Saleem <shiraz.saleem@intel.com>
Tue, 7 Dec 2021 15:21:36 +0000 (09:21 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Dec 2021 09:30:13 +0000 (10:30 +0100)
commit11eebcf63e98fcf047a876a51d76afdabc3b8b9b
treecbc3fe2cd0485f52df27219099a787d53406dab7
parent1ac287b7b61520d00255b4ec8c8e2dd5f0277169
RDMA/irdma: Fix a user-after-free in add_pble_prm

[ Upstream commit 1e11a39a82e95ce86f849f40dda0d9c0498cebd9 ]

When irdma_hmc_sd_one fails, 'chunk' is freed while its still on the PBLE
info list.

Add the chunk entry to the PBLE info list only after successful setting of
the SD in irdma_hmc_sd_one.

Fixes: e8c4dbc2fcac ("RDMA/irdma: Add PBLE resource manager")
Link: https://lore.kernel.org/r/20211207152135.2192-1-shiraz.saleem@intel.com
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/irdma/pble.c