DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, ferruh.yigit@intel.com, stable@dpdk.org,
	Shepard Siegel <shepard.siegel@atomicrules.com>,
	Ed Czeck <ed.czeck@atomicrules.com>,
	John Miller <john.miller@atomicrules.com>,
	Ravi Kumar <ravi1.kumar@amd.com>,
	Beilei Xing <beilei.xing@intel.com>,
	Qi Zhang <qi.z.zhang@intel.com>,
	Qiming Yang <qiming.yang@intel.com>,
	Wenzhuo Lu <wenzhuo.lu@intel.com>,
	Jerin Jacob <jerinj@marvell.com>,
	Maciej Czekaj <mczekaj@marvell.com>
Subject: [dpdk-dev] [PATCH 3/3] drivers/net: fix double free on init failure cleanup
Date: Mon, 17 Jun 2019 17:05:24 +0200	[thread overview]
Message-ID: <1560783924-5355-4-git-send-email-david.marchand@redhat.com> (raw)
In-Reply-To: <1560783924-5355-1-git-send-email-david.marchand@redhat.com>

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>
---
 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 7fd784c..86e500e 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -403,9 +403,9 @@ static void eth_ark_macaddr_remove(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 6b3bc3e..cfb1720 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -700,6 +700,7 @@ static void axgbe_default_config(struct axgbe_port *pdata)
 	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 3cf2c1b..69a9cff 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1600,6 +1600,7 @@ static inline void i40e_config_automask(struct i40e_pf *pf)
 	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 bdbceb4..a7de455 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -1466,6 +1466,7 @@ static int ice_load_pkg(struct rte_eth_dev *dev)
 	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 eb2c11d..ec57692 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -2206,6 +2206,7 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic,
 
 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:
-- 
1.8.3.1


  parent reply	other threads:[~2019-06-17 15:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 15:05 [dpdk-dev] [PATCH 0/3] ethdev mac_addrs cleanups David Marchand
2019-06-17 15:05 ` [dpdk-dev] [PATCH 1/3] net/nfb: avoid memory leak on unplug David Marchand
2019-06-26 17:21   ` Ferruh Yigit
2019-06-17 15:05 ` [dpdk-dev] [PATCH 2/3] net/bnx2x: fix invalid free " David Marchand
2019-06-26 17:21   ` Ferruh Yigit
2019-06-17 15:05 ` David Marchand [this message]
2019-06-26 17:21   ` [dpdk-dev] [dpdk-stable] [PATCH 3/3] drivers/net: fix double free on init failure cleanup Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1560783924-5355-4-git-send-email-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=ed.czeck@atomicrules.com \
    --cc=ferruh.yigit@intel.com \
    --cc=jerinj@marvell.com \
    --cc=john.miller@atomicrules.com \
    --cc=mczekaj@marvell.com \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=ravi1.kumar@amd.com \
    --cc=shepard.siegel@atomicrules.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).