]> git.droids-corp.org - dpdk.git/commitdiff
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 7fd784cd0e3066103001149934e25c76212e7456..86e500ecb30cb63fb7ddc13c897b0246ccff6815 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 6b3bc3eea34f3cc022527e0e9d985e04dec397a8..cfb1720641e5a18f6ebfc31cc04dfa4965c7c3c6 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 33644557bc1cb0a29a35a5d7c0152dfbb61693ed..2b9fc4572290b9ec6e04cc5e8e0456ace4b97dd2 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 203d0a9f9981324605016ba215fc3e3e9222f4ba..1e48bd0bd675bf4b277afc8e1b1c8dfd96a2ac7a 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 eb2c11da53046cb1bc2af2b07aabfc83c7cf6d7c..ec57692fb70532cac262d77283c5ce374fa0d05f 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: