@samitouri / QOSamiQemu / commits / cd0eed37f6

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>

GuoHan Zhao committed Apr 24, 2026 at 11:22 UTC cd0eed37f6d9829f21f442c06961bbb63037eea6
1 file changed -2
hw/vfio-user/pci.c
-2
@@ -280,8 +280,6 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error **errp)
280 vbasedev->proxy = proxy;
281 vfio_user_set_handler(vbasedev, vfio_user_pci_process_req, vdev);
282
283 - vbasedev->name = g_strdup_printf("vfio-user:%s", sock_name);
284 -
283 if (udev->send_queued) {
284 proxy->flags |= VFIO_PROXY_FORCE_QUEUED;
285 }