The following scenario causes a crash in function mlx4_get_ifname
1. On testpmd startup mlx4 device is probed and started
2. mlx4 sriov is disabled. As a result an RMV event is sent to
testpmd which closes the device and nullify the priv struct
members.
3. Running 'show port info all' in testpmd results in segmentation
fault because of accessing NULL pointer priv->ctx

The fix is to return with an error from mlx4_get_ifname() if priv->ctx
member is NULL.

Fixes: 61cbdd419478 ("net/mlx4: separate device control functions")
Cc: sta...@dpdk.org

Signed-off-by: Ophir Munk <ophi...@mellanox.com>
---
 drivers/net/mlx4/mlx4_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c
index 3bc6927..cca5223 100644
--- a/drivers/net/mlx4/mlx4_ethdev.c
+++ b/drivers/net/mlx4/mlx4_ethdev.c
@@ -67,6 +67,9 @@ mlx4_get_ifname(const struct priv *priv, char 
(*ifname)[IF_NAMESIZE])
        char match[IF_NAMESIZE] = "";
 
        {
+               if (priv->ctx == NULL)
+                       return -ENOENT;
+
                MKSTR(path, "%s/device/net", priv->ctx->device->ibdev_path);
 
                dir = opendir(path);
-- 
2.7.4

Reply via email to