patch 'bus/fslmc: fix some VFIO device FD and memory leaks' has been queued to stable release 24.11.9

luca.boccassi at gmail.com luca.boccassi at gmail.com
Thu Nov 5 17:41:30 CET 2026


Hi,

FYI, your patch has been queued to stable release 24.11.9

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/07/26. 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/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/c57fd146a689cb25af44771398bb5caed354286c

Thanks.

Luca Boccassi

---
>From c57fd146a689cb25af44771398bb5caed354286c Mon Sep 17 00:00:00 2001
From: David Marchand <david.marchand at redhat.com>
Date: Thu, 10 Sep 2026 18:41:00 +0200
Subject: [PATCH] bus/fslmc: fix some VFIO device FD and memory leaks

[ upstream commit ba19fbe3894e5991ce5d4b605f7d5be2aa660d38 ]

In case VFIO_DEVICE_GET_INFO fails, the vfio_dev_fd was leaked.
In a similar way, failing to add this device FD in the group list would
result in leaking the FD.

When uninitialising a device or doing a bus cleanup, the per device VFIO
FD and the associated memory used for tracking it were leaked.

Fixes: 57cb02edf122 ("bus/fslmc: enhance MC VFIO multi-process support")

Signed-off-by: David Marchand <david.marchand at redhat.com>
Acked-by: Hemant Agrawal <hemant.agrawal at nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c | 45 ++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 15 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 6c353cd1c4e..46b840aebac 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -199,13 +199,17 @@ static int
 fslmc_vfio_clear_group(int vfio_group_fd)
 {
 	struct fslmc_vfio_group *group;
-	struct fslmc_vfio_device *dev;
 	int clear = 0;
 
 	LIST_FOREACH(group, &s_vfio_container.groups, next) {
 		if (group->fd == vfio_group_fd) {
-			LIST_FOREACH(dev, &group->vfio_devices, next)
+			while (!LIST_EMPTY(&group->vfio_devices)) {
+				struct fslmc_vfio_device *dev = LIST_FIRST(&group->vfio_devices);
+
+				close(dev->fd);
 				LIST_REMOVE(dev, next);
+				rte_free(dev);
+			}
 
 			close(vfio_group_fd);
 			LIST_REMOVE(group, next);
@@ -305,6 +309,8 @@ fslmc_vfio_group_add_dev(int vfio_group_fd,
 		if (group->fd == vfio_group_fd) {
 			dev = rte_zmalloc(NULL,
 				sizeof(struct fslmc_vfio_device), 0);
+			if (dev == NULL)
+				return -ENOMEM;
 			dev->fd = dev_fd;
 			rte_strscpy(dev->dev_name, name, sizeof(dev->dev_name));
 			LIST_INSERT_HEAD(&group->vfio_devices, dev, next);
@@ -320,26 +326,25 @@ fslmc_vfio_group_remove_dev(int vfio_group_fd,
 {
 	struct fslmc_vfio_group *group = NULL;
 	struct fslmc_vfio_device *dev;
-	int removed = 0;
 
 	LIST_FOREACH(group, &s_vfio_container.groups, next) {
 		if (group->fd == vfio_group_fd)
 			break;
 	}
 
-	if (group) {
-		LIST_FOREACH(dev, &group->vfio_devices, next) {
-			if (!strcmp(dev->dev_name, name)) {
-				LIST_REMOVE(dev, next);
-				removed = 1;
-				break;
-			}
+	if (group == NULL)
+		goto err;
+
+	LIST_FOREACH(dev, &group->vfio_devices, next) {
+		if (strcmp(dev->dev_name, name) == 0) {
+			close(dev->fd);
+			LIST_REMOVE(dev, next);
+			rte_free(dev);
+			return 0;
 		}
 	}
 
-	if (removed)
-		return 0;
-
+err:
 	return -ENODEV;
 }
 
@@ -1227,11 +1232,21 @@ fslmc_vfio_setup_device(const char *dev_addr,
 	if (ret) {
 		DPAA2_BUS_ERR("%s cannot get device info err(%d)(%s)",
 			dev_addr, errno, strerror(errno));
+		close(*vfio_dev_fd);
+		*vfio_dev_fd = -1;
 		return ret;
 	}
 
-	return fslmc_vfio_group_add_dev(vfio_group_fd, *vfio_dev_fd,
-			dev_addr);
+	ret = fslmc_vfio_group_add_dev(vfio_group_fd, *vfio_dev_fd, dev_addr);
+	if (ret) {
+		DPAA2_BUS_ERR("%s cannot add device in group err(%d)(%s)",
+			dev_addr, ret, strerror(-ret));
+		close(*vfio_dev_fd);
+		*vfio_dev_fd = -1;
+		return ret;
+	}
+
+	return 0;
 }
 
 static intptr_t vfio_map_mcp_obj(const char *mcp_obj)
-- 
2.47.3

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2026-11-05 16:42:45.182855917 +0000
+++ 0003-bus-fslmc-fix-some-VFIO-device-FD-and-memory-leaks.patch	2026-11-05 16:42:44.885059710 +0000
@@ -1 +1 @@
-From ba19fbe3894e5991ce5d4b605f7d5be2aa660d38 Mon Sep 17 00:00:00 2001
+From c57fd146a689cb25af44771398bb5caed354286c Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit ba19fbe3894e5991ce5d4b605f7d5be2aa660d38 ]
+
@@ -22 +24 @@
-index 2a3d022d2e..10efd98e7b 100644
+index 6c353cd1c4e..46b840aebac 100644
@@ -25 +27 @@
-@@ -217,13 +217,17 @@ static int
+@@ -199,13 +199,17 @@ static int
@@ -45 +47 @@
-@@ -323,6 +327,8 @@ fslmc_vfio_group_add_dev(int vfio_group_fd,
+@@ -305,6 +309,8 @@ fslmc_vfio_group_add_dev(int vfio_group_fd,
@@ -54 +56 @@
-@@ -338,26 +344,25 @@ fslmc_vfio_group_remove_dev(int vfio_group_fd,
+@@ -320,26 +326,25 @@ fslmc_vfio_group_remove_dev(int vfio_group_fd,
@@ -91 +93 @@
-@@ -1251,11 +1256,21 @@ fslmc_vfio_setup_device(const char *dev_addr,
+@@ -1227,11 +1232,21 @@ fslmc_vfio_setup_device(const char *dev_addr,


More information about the stable mailing list