patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] bus/vdev: fix devargs memory leak
@ 2023-09-01  7:24 Mingjin Ye
  2023-09-12  9:07 ` Ling, WeiX
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mingjin Ye @ 2023-09-01  7:24 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, yidingx.zhou, Mingjin Ye, stable, Anatoly Burakov

When a device is created by a secondary process, an empty devargs is
temporarily generated and bound to it. This causes the device to not
be associated with the correct devargs, and the empty devargs are not
released when the resource is freed.

This patch fixes the issue by matching the devargs when inserting a
device in secondary process.

Fixes: dda987315ca2 ("vdev: make virtual bus use its device struct")
Fixes: a16040453968 ("eal: extract vdev infra")
Cc: stable@dpdk.org

Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
---
 drivers/bus/vdev/vdev.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 7974b27295..fe39a98a9c 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -259,6 +259,22 @@ alloc_devargs(const char *name, const char *args)
 	return devargs;
 }
 
+static struct rte_devargs *
+vdev_devargs_lookup(const char *name)
+{
+	struct rte_devargs *devargs;
+	char dev_name[32];
+
+	RTE_EAL_DEVARGS_FOREACH("vdev", devargs) {
+		devargs->bus->parse(devargs->name, &dev_name);
+		if (strcmp(dev_name, name) == 0) {
+			VDEV_LOG(INFO, "**Devargs matched %s", dev_name);
+			return devargs;
+		}
+	}
+	return NULL;
+}
+
 static int
 insert_vdev(const char *name, const char *args,
 		struct rte_vdev_device **p_dev,
@@ -271,7 +287,11 @@ insert_vdev(const char *name, const char *args,
 	if (name == NULL)
 		return -EINVAL;
 
-	devargs = alloc_devargs(name, args);
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+		devargs = alloc_devargs(name, args);
+	else
+		devargs = vdev_devargs_lookup(name);
+
 	if (!devargs)
 		return -ENOMEM;
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-06 14:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01  7:24 [PATCH] bus/vdev: fix devargs memory leak Mingjin Ye
2023-09-12  9:07 ` Ling, WeiX
2023-09-15  8:56   ` Ye, MingjinX
2023-11-07  6:56     ` Ye, MingjinX
2023-11-17 10:29     ` Ye, MingjinX
2024-02-02 14:52 ` Burakov, Anatoly
2024-03-06 14:01 ` Thomas Monjalon

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