79c4324644
Change-Id: I2d302dda68298877c65c99147f5bf22186a59aac
58 lines
2.0 KiB
Diff
58 lines
2.0 KiB
Diff
From 1d888e71517be4a0793b5a03b4a2234c55953c8f Mon Sep 17 00:00:00 2001
|
|
From: boringandboring <wangjinlei_yewu@cmss.chinamobile.com>
|
|
Date: Fri, 8 Dec 2023 10:02:51 +0800
|
|
Subject: [PATCH] virtio/vhost-vsock: don't double close vhostfd, remove
|
|
redundant cleanup
|
|
|
|
cherry picked from d731ab31196579144457c7f2fa3649338bfb21f2
|
|
|
|
In case of an error during initialization in vhost_dev_init, vhostfd is
|
|
closed in vhost_dev_cleanup. Remove close from err_virtio as it's both
|
|
redundant and causes a double close on vhostfd.
|
|
|
|
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
|
|
Message-Id: <20211129125204.1108088-1-d-tatianin@yandex-team.ru>
|
|
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Signed-off-by: boringandboring <wangjinlei_yewu@cmss.chinamobile.com>
|
|
---
|
|
hw/virtio/vhost-vsock.c | 11 +++++------
|
|
1 file changed, 5 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
|
|
index 478c0c9a87..433d42d897 100644
|
|
--- a/hw/virtio/vhost-vsock.c
|
|
+++ b/hw/virtio/vhost-vsock.c
|
|
@@ -171,6 +171,10 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp)
|
|
ret = vhost_dev_init(&vvc->vhost_dev, (void *)(uintptr_t)vhostfd,
|
|
VHOST_BACKEND_TYPE_KERNEL, 0, errp);
|
|
if (ret < 0) {
|
|
+ /*
|
|
+ * vhostfd is closed by vhost_dev_cleanup, which is called
|
|
+ * by vhost_dev_init on initialization error.
|
|
+ */
|
|
goto err_virtio;
|
|
}
|
|
|
|
@@ -183,15 +187,10 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp)
|
|
return;
|
|
|
|
err_vhost_dev:
|
|
- vhost_dev_cleanup(&vvc->vhost_dev);
|
|
/* vhost_dev_cleanup() closes the vhostfd passed to vhost_dev_init() */
|
|
- vhostfd = -1;
|
|
+ vhost_dev_cleanup(&vvc->vhost_dev);
|
|
err_virtio:
|
|
vhost_vsock_common_unrealize(vdev);
|
|
- if (vhostfd >= 0) {
|
|
- close(vhostfd);
|
|
- }
|
|
- return;
|
|
}
|
|
|
|
static void vhost_vsock_device_unrealize(DeviceState *dev)
|
|
--
|
|
2.27.0
|
|
|