[dpdk-dev] [PATCH] net/mlx5: fix verification of device context

Shachar Beiser shacharbe at mellanox.com
Wed Jul 26 07:43:24 CEST 2017


Get interface name function lacks verification of device context.
It might lead to segmentation fault when trying to query the name
after the device is closed.fixing it by adding the missing verification

Fixes: cd89f22a1e9770 ("net/mlx5: remove unused interface name query")
Cc: stable at dpdk.org

Signed-off-by: Shachar Beiser <shacharbe at mellanox.com>
---
 drivers/net/mlx5/mlx5_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index b70b7b9..6e67461 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -173,6 +173,10 @@ struct priv *
 	char match[IF_NAMESIZE] = "";
 
 	{
+		if (priv->ctx == NULL) {
+			DEBUG("The device is closed, cannot query interface name ");
+			return -1;
+		}
 		MKSTR(path, "%s/device/net", priv->ctx->device->ibdev_path);
 
 		dir = opendir(path);
-- 
1.8.3.1



More information about the dev mailing list