[PATCH v2 5/9] net/ixgbe: fix VF representor port leak

Anurag Mandal anurag.mandal at intel.com
Tue Dec 1 11:55:16 CET 2026


VF representor ports are never released.

They have no close callback, so rte_eth_dev_close()
returns -ENOTSUP before releasing the port.
On device removal, eth_ixgbe_pci_remove() looks up
the port by the PCI device name, which always finds
the PF, so the representor branch is dead code.
Each representor leaks its port and private data,
and its MAC address pointer is left pointing into the
per-VF data of the PF, which is freed when the PF is
closed.

Add a close callback for representors, and release
them before the PF on device removal, failing the
removal if one cannot be released so the PF is not
removed underneath it.
As close may also be called from a secondary process,
only clear the shared MAC address pointer in the primary.

Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")
Cc: stable at dpdk.org

Signed-off-by: Anurag Mandal <anurag.mandal at intel.com>
---
 drivers/net/intel/ixgbe/ixgbe_ethdev.c        | 24 ++++++++++++-------
 .../net/intel/ixgbe/ixgbe_vf_representor.c    |  5 +++-
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/net/intel/ixgbe/ixgbe_ethdev.c b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
index 475045c825..8b1ffb0739 100644
--- a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
@@ -1711,17 +1711,23 @@ eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
 {
 	struct rte_eth_dev *ethdev;
+	uint16_t port_id;
+	int ret;
 
-	ethdev = rte_eth_dev_allocated(pci_dev->device.name);
-	if (!ethdev)
-		return 0;
+	/* representors point into PF private data, so release them first */
+	RTE_ETH_FOREACH_DEV_OF(port_id, &pci_dev->device) {
+		ethdev = &rte_eth_devices[port_id];
+		if (!rte_eth_dev_is_repr(ethdev))
+			continue;
+		ret = rte_eth_dev_destroy(ethdev, ixgbe_vf_representor_uninit);
+		if (ret != 0) {
+			PMD_DRV_LOG(ERR, "failed to release representor port %u: %d",
+				    port_id, ret);
+			return ret;
+		}
+	}
 
-	if (rte_eth_dev_is_repr(ethdev))
-		return rte_eth_dev_pci_generic_remove(pci_dev,
-					ixgbe_vf_representor_uninit);
-	else
-		return rte_eth_dev_pci_generic_remove(pci_dev,
-						eth_ixgbe_dev_uninit);
+	return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbe_dev_uninit);
 }
 
 static struct rte_pci_driver rte_ixgbe_pmd = {
diff --git a/drivers/net/intel/ixgbe/ixgbe_vf_representor.c b/drivers/net/intel/ixgbe/ixgbe_vf_representor.c
index c11983e307..83f8f667a9 100644
--- a/drivers/net/intel/ixgbe/ixgbe_vf_representor.c
+++ b/drivers/net/intel/ixgbe/ixgbe_vf_representor.c
@@ -5,6 +5,7 @@
 #include <rte_ethdev.h>
 #include <rte_pci.h>
 #include <rte_malloc.h>
+#include <rte_eal.h>
 
 #include "ethdev_driver.h"
 #include "base/ixgbe_type.h"
@@ -173,6 +174,7 @@ static const struct eth_dev_ops ixgbe_vf_representor_dev_ops = {
 	.dev_start		= ixgbe_vf_representor_dev_start,
 	.dev_configure		= ixgbe_vf_representor_dev_configure,
 	.dev_stop		= ixgbe_vf_representor_dev_stop,
+	.dev_close		= ixgbe_vf_representor_uninit,
 
 	.rx_queue_setup		= ixgbe_vf_representor_rx_queue_setup,
 	.tx_queue_setup		= ixgbe_vf_representor_tx_queue_setup,
@@ -267,7 +269,8 @@ int
 ixgbe_vf_representor_uninit(struct rte_eth_dev *ethdev)
 {
 	/* mac_addrs must not be freed because part of ixgbe_vf_info */
-	ethdev->data->mac_addrs = NULL;
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+		ethdev->data->mac_addrs = NULL;
 
 	return 0;
 }
-- 
2.25.1



More information about the stable mailing list