Commit cd0eed37f6 for qemu.org
commit cd0eed37f6d9829f21f442c06961bbb63037eea6
Author: GuoHan Zhao <zhaoguohan@kylinos.cn>
Date: Fri Apr 24 11:22:09 2026 +0800
vfio-user: avoid leaking duplicate device name
vfio_user_pci_realize() assigns vbasedev->name before connecting to the
server, then assigns the same name again after installing the request
handler. The second assignment overwrites the first allocation, so only
the second string can be freed later by vfio_device_free_name().
Drop the duplicate assignment and keep the first name allocation, which is
also available on connection failures for error reporting.
Fixes: 36227628d824 ("vfio-user: implement message send infrastructure")
Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20260424032209.297458-1-zhaoguohan@kylinos.cn
Signed-off-by: Cédric Le Goater <clg@redhat.com>
diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c
index facc79727a..e7573d4a9f 100644
--- a/hw/vfio-user/pci.c
+++ b/hw/vfio-user/pci.c
@@ -280,8 +280,6 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error **errp)
vbasedev->proxy = proxy;
vfio_user_set_handler(vbasedev, vfio_user_pci_process_req, vdev);
- vbasedev->name = g_strdup_printf("vfio-user:%s", sock_name);
-
if (udev->send_queued) {
proxy->flags |= VFIO_PROXY_FORCE_QUEUED;
}