diff mbox series

net/pcap: fix fd leak on uninit

Message ID ME3P282MB166802B16DBFB7E39FD71994D1999@ME3P282MB1668.AUSP282.PROD.OUTLOOK.COM (mailing list archive)
State Accepted
Delegated to: Ferruh Yigit
Headers show
Series net/pcap: fix fd leak on uninit | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success travis build: passed
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Tengfei Zhang March 2, 2021, 4:51 p.m. UTC
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 <zypscode@outlook.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Ferruh Yigit March 3, 2021, 2:26 p.m. UTC | #1
On 3/2/2021 4:51 PM, Tengfei Zhang wrote:
> 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 <zypscode@outlook.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.
diff mbox series

Patch

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 90f5d75ea..49b9a1f44 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -621,9 +621,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) {
-		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;
 	}
 
@@ -755,6 +757,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)