drivers/net: fix double free on init failure
authorDavid Marchand <david.marchand@redhat.com>
Mon, 17 Jun 2019 15:05:24 +0000 (17:05 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 28 Jun 2019 18:31:49 +0000 (20:31 +0200)
If we don't clear mac_addrs, ethdev will double free it on cleanup.

Fixes: e16adf08e54d ("ethdev: free all common data when releasing port")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/ark/ark_ethdev.c
drivers/net/axgbe/axgbe_ethdev.c
drivers/net/i40e/i40e_ethdev.c
drivers/net/ice/ice_ethdev.c
drivers/net/thunderx/nicvf_ethdev.c

index 7fd784c..86e500e 100644 (file)
@@ -403,9 +403,9 @@ eth_ark_dev_init(struct rte_eth_dev *dev)
 
        return ret;
 
- error:
-       if (dev->data->mac_addrs)
-               rte_free(dev->data->mac_addrs);
+error:
+       rte_free(dev->data->mac_addrs);
+       dev->data->mac_addrs = NULL;
        return -1;
 }
 
index 6b3bc3e..cfb1720 100644 (file)
@@ -700,6 +700,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
        ret = pdata->phy_if.phy_init(pdata);
        if (ret) {
                rte_free(eth_dev->data->mac_addrs);
+               eth_dev->data->mac_addrs = NULL;
                return ret;
        }
 
index 3364455..2b9fc45 100644 (file)
@@ -1595,6 +1595,7 @@ err_init_tunnel_filter_list:
        rte_free(pf->ethertype.hash_map);
 err_init_ethtype_filter_list:
        rte_free(dev->data->mac_addrs);
+       dev->data->mac_addrs = NULL;
 err_mac_alloc:
        i40e_vsi_release(pf->main_vsi);
 err_setup_pf_switch:
index 203d0a9..1e48bd0 100644 (file)
@@ -1466,6 +1466,7 @@ err_pf_setup:
        ice_res_pool_destroy(&pf->msix_pool);
 err_msix_pool_init:
        rte_free(dev->data->mac_addrs);
+       dev->data->mac_addrs = NULL;
 err_init_mac:
        ice_sched_cleanup_all(hw);
        rte_free(hw->port_info);
index eb2c11d..ec57692 100644 (file)
@@ -2206,6 +2206,7 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
 
 malloc_fail:
        rte_free(eth_dev->data->mac_addrs);
+       eth_dev->data->mac_addrs = NULL;
 alarm_fail:
        nicvf_periodic_alarm_stop(nicvf_interrupt, eth_dev);
 fail: