* [dpdk-dev] [PATCH 0/3] ethdev mac_addrs cleanups
@ 2019-06-17 15:05 David Marchand
2019-06-17 15:05 ` [dpdk-dev] [PATCH 1/3] net/nfb: avoid memory leak on unplug David Marchand
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: David Marchand @ 2019-06-17 15:05 UTC (permalink / raw)
To: dev; +Cc: thomas, ferruh.yigit
A little series of fixes caught by code review.
I do not have all those hw and reaching those error branch is not an
easy thing to do anyway, so please review carefully.
Thanks.
--
David Marchand
David Marchand (3):
net/nfb: avoid memory leak on unplug
net/bnx2x: fix invalid free on unplug
drivers/net: fix double free on init failure cleanup
drivers/net/ark/ark_ethdev.c | 6 +++---
drivers/net/axgbe/axgbe_ethdev.c | 1 +
drivers/net/bnx2x/bnx2x_ethdev.c | 9 ++++++++-
drivers/net/i40e/i40e_ethdev.c | 1 +
drivers/net/ice/ice_ethdev.c | 1 +
drivers/net/nfb/nfb_ethdev.c | 2 --
drivers/net/thunderx/nicvf_ethdev.c | 1 +
7 files changed, 15 insertions(+), 6 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH 1/3] net/nfb: avoid memory leak on unplug
2019-06-17 15:05 [dpdk-dev] [PATCH 0/3] ethdev mac_addrs cleanups David Marchand
@ 2019-06-17 15:05 ` 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-17 15:05 ` [dpdk-dev] [PATCH 3/3] drivers/net: fix double free on init failure cleanup David Marchand
2 siblings, 1 reply; 7+ messages in thread
From: David Marchand @ 2019-06-17 15:05 UTC (permalink / raw)
To: dev; +Cc: thomas, ferruh.yigit, Rastislav Cernay, Jan Remes
Clearing mac_addrs on remove will prevent ethdev from freeing it.
Fixes: 6435f9a0ac22 ("net/nfb: add new netcope driver")
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
drivers/net/nfb/nfb_ethdev.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index fdd0e70..6f77864 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -510,8 +510,6 @@
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
struct rte_pci_addr *pci_addr = &pci_dev->addr;
- dev->data->mac_addrs = NULL;
-
nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
--
1.8.3.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH 2/3] net/bnx2x: fix invalid free on unplug
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-17 15:05 ` David Marchand
2019-06-26 17:21 ` Ferruh Yigit
2019-06-17 15:05 ` [dpdk-dev] [PATCH 3/3] drivers/net: fix double free on init failure cleanup David Marchand
2 siblings, 1 reply; 7+ messages in thread
From: David Marchand @ 2019-06-17 15:05 UTC (permalink / raw)
To: dev; +Cc: thomas, ferruh.yigit, stable, Rasesh Mody, Shahed Shaikh
mac_addrs points to a field in dev_private.
We can't let ethdev free it.
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/bnx2x/bnx2x_ethdev.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 45c6c36..f47a73c 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -701,6 +701,13 @@ void bnx2x_periodic_stop(void *param)
return bnx2x_common_dev_init(eth_dev, 1);
}
+static int eth_bnx2x_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+ /* mac_addrs must not be freed alone because part of dev_private */
+ eth_dev->data->mac_addrs = NULL;
+ return 0;
+}
+
static struct rte_pci_driver rte_bnx2x_pmd;
static struct rte_pci_driver rte_bnx2xvf_pmd;
@@ -719,7 +726,7 @@ static int eth_bnx2x_pci_probe(struct rte_pci_driver *pci_drv,
static int eth_bnx2x_pci_remove(struct rte_pci_device *pci_dev)
{
- return rte_eth_dev_pci_generic_remove(pci_dev, NULL);
+ return rte_eth_dev_pci_generic_remove(pci_dev, eth_bnx2x_dev_uninit);
}
static struct rte_pci_driver rte_bnx2x_pmd = {
--
1.8.3.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH 3/3] drivers/net: fix double free on init failure cleanup
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-17 15:05 ` [dpdk-dev] [PATCH 2/3] net/bnx2x: fix invalid free " David Marchand
@ 2019-06-17 15:05 ` David Marchand
2019-06-26 17:21 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2 siblings, 1 reply; 7+ messages in thread
From: David Marchand @ 2019-06-17 15:05 UTC (permalink / raw)
To: dev
Cc: thomas, ferruh.yigit, stable, Shepard Siegel, Ed Czeck,
John Miller, Ravi Kumar, Beilei Xing, Qi Zhang, Qiming Yang,
Wenzhuo Lu, Jerin Jacob, Maciej Czekaj
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] net/nfb: avoid memory leak on unplug
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
0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2019-06-26 17:21 UTC (permalink / raw)
To: David Marchand, dev; +Cc: thomas, Rastislav Cernay, Jan Remes
On 6/17/2019 4:05 PM, David Marchand wrote:
> Clearing mac_addrs on remove will prevent ethdev from freeing it.
>
> Fixes: 6435f9a0ac22 ("net/nfb: add new netcope driver")
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] net/bnx2x: fix invalid free on unplug
2019-06-17 15:05 ` [dpdk-dev] [PATCH 2/3] net/bnx2x: fix invalid free " David Marchand
@ 2019-06-26 17:21 ` Ferruh Yigit
0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2019-06-26 17:21 UTC (permalink / raw)
To: David Marchand, dev; +Cc: thomas, stable, Rasesh Mody, Shahed Shaikh
On 6/17/2019 4:05 PM, David Marchand wrote:
> mac_addrs points to a field in dev_private.
> We can't let ethdev free it.
>
> 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>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH 3/3] drivers/net: fix double free on init failure cleanup
2019-06-17 15:05 ` [dpdk-dev] [PATCH 3/3] drivers/net: fix double free on init failure cleanup David Marchand
@ 2019-06-26 17:21 ` Ferruh Yigit
0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2019-06-26 17:21 UTC (permalink / raw)
To: David Marchand, dev
Cc: thomas, stable, Shepard Siegel, Ed Czeck, John Miller,
Ravi Kumar, Beilei Xing, Qi Zhang, Qiming Yang, Wenzhuo Lu,
Jerin Jacob, Maciej Czekaj
On 6/17/2019 4:05 PM, David Marchand wrote:
> 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>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-06-26 17:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [dpdk-dev] [PATCH 3/3] drivers/net: fix double free on init failure cleanup David Marchand
2019-06-26 17:21 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
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).