From e412a138db918019cbd883132f81860951515a9b Mon Sep 17 00:00:00 2001 From: Tengfei Zhang Date: Tue, 2 Mar 2021 16:51:30 +0000 Subject: [PATCH] net/pcap: fix file descriptor leak on close pcap fd was opend when vdev probed, but not closed when vdev removed. Fixes: c956caa6eabf ("pcap: support port hotplug") Cc: stable@dpdk.org Signed-off-by: Tengfei Zhang Acked-by: Ferruh Yigit --- drivers/net/pcap/rte_eth_pcap.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 2766745a71..28a5027315 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -682,9 +682,11 @@ eth_dev_stop(struct rte_eth_dev *dev) /* Special iface case. Single pcap is open and shared between tx/rx. */ if (internals->single_iface) { queue_missed_stat_on_stop_update(dev, 0); - pcap_close(pp->tx_pcap[0]); - pp->tx_pcap[0] = NULL; - pp->rx_pcap[0] = NULL; + if (pp->tx_pcap[0] != NULL) { + pcap_close(pp->tx_pcap[0]); + pp->tx_pcap[0] = NULL; + pp->rx_pcap[0] = NULL; + } goto status_down; } @@ -821,6 +823,8 @@ eth_dev_close(struct rte_eth_dev *dev) PMD_LOG(INFO, "Closing pcap ethdev on NUMA socket %d", rte_socket_id()); + eth_dev_stop(dev); + rte_free(dev->process_private); if (rte_eal_process_type() != RTE_PROC_PRIMARY) -- 2.20.1