]> git.droids-corp.org - dpdk.git/commitdiff
net/mlx5: fix sharing context destroy order
authorViacheslav Ovsiienko <viacheslavo@mellanox.com>
Fri, 5 Apr 2019 13:29:05 +0000 (13:29 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 12 Apr 2019 09:02:02 +0000 (11:02 +0200)
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>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
drivers/net/mlx5/mlx5.c

index b7e62349dbfac82ea670b8dc6c1af5d35ea8ca97..475c93ddf9f488edd99860a79a3b0d91471da6f0 100644 (file)
@@ -593,9 +593,6 @@ mlx5_dev_close(struct rte_eth_dev *dev)
        mlx5_mr_release(dev);
        assert(priv->sh);
        mlx5_free_shared_dr(priv);
-       if (priv->sh)
-               mlx5_free_shared_ibctx(priv->sh);
-       priv->sh = NULL;
        if (priv->rss_conf.rss_key != NULL)
                rte_free(priv->rss_conf.rss_key);
        if (priv->reta_idx != NULL)
@@ -608,6 +605,16 @@ mlx5_dev_close(struct rte_eth_dev *dev)
                close(priv->nl_socket_rdma);
        if (priv->tcf_context)
                mlx5_flow_tcf_context_destroy(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",