From e7f2fa88a71eb667788a124abbdc6d1ca1e0671e Mon Sep 17 00:00:00 2001 From: David Marchand Date: Mon, 17 Jun 2019 17:05:24 +0200 Subject: [PATCH] drivers/net: fix double free on init failure 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 Reviewed-by: Ferruh Yigit --- drivers/net/ark/ark_ethdev.c | 6 +++--- drivers/net/axgbe/axgbe_ethdev.c | 1 + drivers/net/i40e/i40e_ethdev.c | 1 + drivers/net/ice/ice_ethdev.c | 1 + drivers/net/thunderx/nicvf_ethdev.c | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index 7fd784cd0e..86e500ecb3 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -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; } diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index 6b3bc3eea3..cfb1720641 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -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; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 33644557bc..2b9fc45722 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -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: diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 203d0a9f99..1e48bd0bd6 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -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); diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index eb2c11da53..ec57692fb7 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -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: -- 2.20.1