[PATCH v1 1/2] bus/vdev: fix memory leak

Wenjun Wu wenjun1.wu at intel.com
Wed Jul 5 11:25:10 CEST 2023


In hotplug usecase, devargs will be allocated in secondary process
in the function alloc_devargs. Since it will not be insert into the
devarg_list, it will have no chance to be freed.

This patch adds additional memory free for device structure member devargs
in the secondary process in rte_vdev_uninit.

Fixes: f5b2eff0847d ("bus/vdev: fix devargs after multi-process bus scan")
Cc: stable at dpdk.org

Signed-off-by: Wenjun Wu <wenjun1.wu at intel.com>
---
 drivers/bus/vdev/vdev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 7974b27295..3f4e6a1b55 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -373,6 +373,11 @@ rte_vdev_uninit(const char *name)
 
 	TAILQ_REMOVE(&vdev_device_list, dev, next);
 	rte_devargs_remove(dev->device.devargs);
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
+	    dev->device.devargs != NULL) {
+		rte_devargs_reset(dev->device.devargs);
+		free(dev->device.devargs);
+	}
 	free(dev);
 
 unlock:
-- 
2.34.1



More information about the stable mailing list