Skip to contentSkip to conversation

IB/mlx5: Fix mlx5_ib_alloc_mr error flow

PATCH Applied Leon Romanovsky 2 participants 2 messages Dec 26, 2017 – Dec 27, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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()).

Fixes 8a187ee52b04 ("IB/mlx5: Support the new memory registration API")
---
 drivers/infiniband/hw/mlx5/mr.c | 1 +
 1 file changed, 1 insertion(+)
drivers/infiniband/hw/mlx5/mr.c +1 -0
index ee0ee1f9994b..d109fe8290a7 100644
@@ -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

#2 lore raw
Quoted 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 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()).

Quoted 6 lines
Fixes 8a187ee52b04 ("IB/mlx5: Support the new memory registration API")
 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