From eaa45270aa6646aefc223d0734e14ccb8838c2ef Mon Sep 17 00:00:00 2001 From: David Marchand Date: Mon, 17 Jun 2019 17:05:23 +0200 Subject: [PATCH] net/bnx2x: fix invalid free on unplug 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 Reviewed-by: Ferruh Yigit --- 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 0ee35e4e4d..10b4fdb8ec 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c +++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -700,6 +700,13 @@ eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev) 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; @@ -718,7 +725,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 = { -- 2.20.1