diff mbox series

[1/1] net/mlx5: fix sharing context destroy order

Message ID 1554300897-24032-1-git-send-email-viacheslavo@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Shahaf Shuler
Headers show
Series [1/1] net/mlx5: fix sharing context destroy order | expand


Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply issues

Commit Message

Slava Ovsiienko April 3, 2019, 2:14 p.m. UTC
At the mlx5 device closing the shared IB context was destroyed
before cleanup routines completion. As it was found on some
setups (Netlink fails with old kernel drivers and we have to use
sysfs to retrieve interface index, this requires IB device name,
which is stored in shared context) the mlx5_nl_mac_addr_flush()
requires IB device name, and if shared context is removed it
causes the segmentation fault.

Fixes: 17e19bc4dde7 ("net/mlx5: add IB shared context alloc/free functions")

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
 drivers/net/mlx5/mlx5.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff mbox series


diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 9aa5f0b..570640d 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -543,9 +543,6 @@  struct mlx5_dev_spawn_data {
 #ifdef HAVE_MLX5DV_DR
-	if (priv->sh)
-		mlx5_free_shared_ibctx(priv->sh);
-	priv->sh = NULL;
 	if (priv->rss_conf.rss_key != NULL)
 	if (priv->reta_idx != NULL)
@@ -560,6 +557,16 @@  struct mlx5_dev_spawn_data {
 	if (priv->tcf_context)
+	if (priv->sh) {
+		/*
+		 * Free the shared context in last turn, because the cleanup
+		 * routines above may use some shared fields, like
+		 * mlx5_nl_mac_addr_flush() uses ibdev_path for retrieveing
+		 * ifindex if Netlink fails.
+		 */
+		mlx5_free_shared_ibctx(priv->sh);
+		priv->sh = NULL;
+	}
 	ret = mlx5_hrxq_ibv_verify(dev);
 	if (ret)
 		DRV_LOG(WARNING, "port %u some hash Rx queue still remain",