DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tengfei Zhang <zypscode@outlook.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org, Tengfei Zhang <zypscode@outlook.com>, stable@dpdk.org
Subject: [dpdk-dev] [PATCH] net/pcap: fix fd leak on uninit
Date: Tue,  2 Mar 2021 16:51:30 +0000	[thread overview]
Message-ID: <ME3P282MB166802B16DBFB7E39FD71994D1999@ME3P282MB1668.AUSP282.PROD.OUTLOOK.COM> (raw)

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(-)

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)
-- 
2.25.1


             reply	other threads:[~2021-03-02 16:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 16:51 Tengfei Zhang [this message]
2021-03-03 14:26 ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ME3P282MB166802B16DBFB7E39FD71994D1999@ME3P282MB1668.AUSP282.PROD.OUTLOOK.COM \
    --to=zypscode@outlook.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).