Inserting a vdev device when the device arguments are already stored
in devargs_list, the rte_devargs_insert function replaces the supplied
new devargs with the found devargs and frees the new devargs. As a
result, the use of free devargs results in a core dump.

This patch fixes the issue by using valid devargs.

Fixes: f3a1188cee4a ("devargs: make device representation generic")
Cc: sta...@dpdk.org

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

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 1a6cc7d12d..53fc4a6e21 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -286,7 +286,6 @@ insert_vdev(const char *name, const char *args, struct 
rte_vdev_device **p_dev)
 
        dev->device.bus = &rte_vdev_bus;
        dev->device.numa_node = SOCKET_ID_ANY;
-       dev->device.name = devargs->name;
 
        if (find_vdev(name)) {
                /*
@@ -300,6 +299,7 @@ insert_vdev(const char *name, const char *args, struct 
rte_vdev_device **p_dev)
 
        rte_devargs_insert(&devargs);
        dev->device.devargs = devargs;
+       dev->device.name = devargs->name;
        TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
 
        if (p_dev)
-- 
2.25.1

Reply via email to