IB/mlx5: Fix mlx5_ib_alloc_mr error flow
Subsystems (2)
PATCH 1/1 IB/mlx5: Fix mlx5_ib_alloc_mr error flow
From: Nitzan Carmi <nitzanc-VPRAkNaXOzVWk0Htik3J/[email protected]>
ibmr.device is being set only after ib_alloc_mr() is (successfully) complete. Therefore, in case mlx5_core_create_mkey() return with error, the error flow calls mlx5_free_priv_descs() which uses ibmr.device (which doesn't exist yet), causing NULL dereference and gets the system into kernel panic.
To fix this, the IB device should be given to mr struct in earlier stage (e.g. prior to calling mlx5_core_create_mkey()).
--- drivers/infiniband/hw/mlx5/mr.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/mlx5/mr.c +1 -0
@@ -1637,6 +1637,7 @@ struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd,MLX5_SET (mkc, mkc, access_mode, mr->access_mode);MLX5_SET (mkc, mkc, umr_en,1 ); + mr->ibmr.device = pd->device; err =mlx5_core_create_mkey (dev->mdev, &mr->mmkey, in, inlen);if (err) goto err_destroy_psv;
--
2.15.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20171226092020.8106-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Jason Gunthorpe
AppliedQuoted 11 lines · Leon Romanovsky
From: Nitzan Carmi <nitzanc-VPRAkNaXOzVWk0Htik3J/[email protected]>
ibmr.device is being set only after
ib_alloc_mr()is (successfully) complete. Therefore, in casemlx5_core_create_mkey()return with error, the error flow callsmlx5_free_priv_descs()which uses ibmr.device (which doesn't exist yet), causing NULL dereference and gets the system into kernel panic.To fix this, the IB device should be given to mr struct in earlier stage (e.g. prior to calling
mlx5_core_create_mkey()).
Quoted 6 lines
Fixes 8a187ee52b04 ("IB/mlx5: Support the new memory registration API")Signed-off-by Leon Romanovsky <[email protected]>drivers/infiniband/hw/mlx5/mr.c | 1 + 1 file changed, 1 insertion(+)
Applied to for-rc, thanks
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html