On Thu, Aug 20, 2026 at 02:39:49PM +0300, Andrey Drobyshev wrote:
In vhost_vsock_device_realize(), after unsuccessful call to
qemu_set_blocking(vhostfd, false), vhostfd gets leaked. Let's close it
explicitly in this case. CPR-saved FDs don't get automatically closed,
thus it is safe both for vhostfd obtained from cpr_find_fd() and from
open(/dev/vhost-vsock).
Fixes tag?
Signed-off-by: Andrey Drobyshev <[email protected]>
---
hw/virtio/vhost-vsock.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
Reviewed-by: Stefano Garzarella <[email protected]>
diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index c582ac9fcc8..3ec20d87606 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -176,20 +176,17 @@ static void vhost_vsock_device_realize(DeviceState *dev,
Error **errp)
error_prepend(errp, "vhost-vsock: unable to parse vhostfd: ");
goto err_blocker;
}
-
- if (!qemu_set_blocking(vhostfd, false, errp)) {
- goto err_blocker;
- }
} else {
vhostfd = open("/dev/vhost-vsock", O_RDWR);
if (vhostfd < 0) {
error_setg_file_open(errp, errno, "/dev/vhost-vsock");
goto err_blocker;
}
+ }
- if (!qemu_set_blocking(vhostfd, false, errp)) {
- goto err_blocker;
- }
+ if (!qemu_set_blocking(vhostfd, false, errp)) {
+ close(vhostfd);
+ goto err_blocker;
}
vhost_vsock_common_realize(vdev);
--
2.47.1