net/mlx5: fix double free on error handling
authorRaslan Darawsheh <rasland@mellanox.com>
Tue, 8 May 2018 09:11:26 +0000 (12:11 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 14 May 2018 21:31:49 +0000 (22:31 +0100)
When attr_ctx is NULL it will attempt to free the list of devices twice.
Avoid double freeing the list by directly going to error handling.

Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")
Cc: stable@dpdk.org
Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
drivers/net/mlx5/mlx5.c

index 3885b0b..05d4f02 100644 (file)
@@ -690,18 +690,18 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
                break;
        }
        if (attr_ctx == NULL) {
-               mlx5_glue->free_device_list(list);
                switch (err) {
                case 0:
                        DRV_LOG(ERR,
                                "cannot access device, is mlx5_ib loaded?");
                        err = ENODEV;
-                       goto error;
+                       break;
                case EINVAL:
                        DRV_LOG(ERR,
                                "cannot use device, are drivers up to date?");
-                       goto error;
+                       break;
                }
+               goto error;
        }
        ibv_dev = list[i];
        DRV_LOG(DEBUG, "device opened");