[2/3] net/bnx2x: fix invalid free on unplug

Message ID 1560783924-5355-3-git-send-email-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series ethdev mac_addrs cleanups |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

David Marchand June 17, 2019, 3:05 p.m. UTC
  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(-)
  

Comments

Ferruh Yigit June 26, 2019, 5:21 p.m. UTC | #1
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.
  

Patch

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 = {