patch 'net/pcap: fix resource leakage on port probe' has been queued to stable release 19.11.11

christian.ehrhardt at canonical.com christian.ehrhardt at canonical.com
Tue Nov 30 17:33:44 CET 2021


Hi,

FYI, your patch has been queued to stable release 19.11.11

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before December 10th 2021. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/cpaelzer/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/cpaelzer/dpdk-stable-queue/commit/a9c743e39971b254f27745fbff6892e43e355eee

Thanks.

Christian Ehrhardt <christian.ehrhardt at canonical.com>

---
>From a9c743e39971b254f27745fbff6892e43e355eee Mon Sep 17 00:00:00 2001
From: Qiming Chen <chenqiming_huawei at 163.com>
Date: Mon, 30 Aug 2021 11:01:08 +0800
Subject: [PATCH] net/pcap: fix resource leakage on port probe

[ upstream commit da0280b3a34c6f67f7e558fcc86c3110816fea28 ]

When the port is probed, if the eth_from_pcaps function fails, the
previously opened pcap resources are not released, causing resource
leakage.

The patch solves the problem of resource leakage caused by abnormal
branch exit during the port probe process.

Fixes: 4c173302c307 ("pcap: add new driver")

Signed-off-by: Qiming Chen <chenqiming_huawei at 163.com>
Acked-by: Ferruh Yigit <ferruh.yigit at intel.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 9ac0a11ffb..619868c510 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -1336,6 +1336,33 @@ eth_from_pcaps(struct rte_vdev_device *vdev,
 	return 0;
 }
 
+static void
+eth_release_pcaps(struct pmd_devargs *pcaps,
+		struct pmd_devargs *dumpers,
+		int single_iface)
+{
+	unsigned int i;
+
+	if (single_iface) {
+		if (pcaps->queue[0].pcap)
+			pcap_close(pcaps->queue[0].pcap);
+		return;
+	}
+
+	for (i = 0; i < dumpers->num_of_queue; i++) {
+		if (dumpers->queue[i].dumper)
+			pcap_dump_close(dumpers->queue[i].dumper);
+
+		if (dumpers->queue[i].pcap)
+			pcap_close(dumpers->queue[i].pcap);
+	}
+
+	for (i = 0; i < pcaps->num_of_queue; i++) {
+		if (pcaps->queue[i].pcap)
+			pcap_close(pcaps->queue[i].pcap);
+	}
+}
+
 static int
 pmd_pcap_probe(struct rte_vdev_device *dev)
 {
@@ -1549,6 +1576,9 @@ create_eth:
 free_kvlist:
 	rte_kvargs_free(kvlist);
 
+	if (ret < 0)
+		eth_release_pcaps(&pcaps, &dumpers, devargs_all.single_iface);
+
 	return ret;
 }
 
-- 
2.34.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-11-30 16:50:07.285103065 +0100
+++ 0020-net-pcap-fix-resource-leakage-on-port-probe.patch	2021-11-30 16:50:05.558871827 +0100
@@ -1 +1 @@
-From da0280b3a34c6f67f7e558fcc86c3110816fea28 Mon Sep 17 00:00:00 2001
+From a9c743e39971b254f27745fbff6892e43e355eee Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit da0280b3a34c6f67f7e558fcc86c3110816fea28 ]
+
@@ -14 +15,0 @@
-Cc: stable at dpdk.org
@@ -19 +20 @@
- drivers/net/pcap/pcap_ethdev.c | 30 ++++++++++++++++++++++++++++++
+ drivers/net/pcap/rte_eth_pcap.c | 30 ++++++++++++++++++++++++++++++
@@ -22,5 +23,5 @@
-diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
-index a8774b7a43..5c4cdbf873 100644
---- a/drivers/net/pcap/pcap_ethdev.c
-+++ b/drivers/net/pcap/pcap_ethdev.c
-@@ -1362,6 +1362,33 @@ eth_from_pcaps(struct rte_vdev_device *vdev,
+diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
+index 9ac0a11ffb..619868c510 100644
+--- a/drivers/net/pcap/rte_eth_pcap.c
++++ b/drivers/net/pcap/rte_eth_pcap.c
+@@ -1336,6 +1336,33 @@ eth_from_pcaps(struct rte_vdev_device *vdev,
@@ -60 +61 @@
-@@ -1582,6 +1609,9 @@ create_eth:
+@@ -1549,6 +1576,9 @@ create_eth:


More information about the stable mailing list