In secondary processes, insert_vdev() may be called multiple times on the same device due to multi-process hot-plugging of the vdev bus and EAL parameters to add the same vdev.
In this case, when rte_devargs_insert() is called, the devargs->name reference will be invalidated because rte_devargs_insert() destroys the just-allocated devargs and replaces the pointer from the devargs list. As a result, the reference to devargs->name stored in dev->device.name will be invalid. This patch fixes the issue by setting the device name after calling rte_devargs_insert(). Fixes: cdb068f031c6 ("bus/vdev: scan by multi-process channel") Cc: sta...@dpdk.org Signed-off-by: Mingjin Ye <mingjinx...@intel.com> --- v2: Modify commit log. --- 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 38d05a9fe9..ec7abe7cda 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -288,7 +288,6 @@ insert_vdev(const char *name, const char *args, dev->device.bus = &rte_vdev_bus; dev->device.numa_node = SOCKET_ID_ANY; - dev->device.name = devargs->name; if (find_vdev(name)) { /* @@ -303,6 +302,7 @@ insert_vdev(const char *name, const char *args, if (init) 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