- vdpa: suspend function return 0 when the vdpa device is stopped - vdpa: don't suspend/resume device when vdpa device not started - vdpa: support vdpa device suspend/resume - vdpa: correct param passed in when unregister save - vdpa: set vring enable only if the vring address has already been set - shadow_dev: introduce shadow dev for virtio-net device - revert "tcg/loongarch64: Fix tcg_out_mov() Aborted" - migration: Set downtime_start even for postcopy - gdb-xml: fix duplicate register in arm-neon.xml - iotests: fix default machine type detection - migration: fix RAMBlock add NULL check - s390x: Fix spelling errors - ppc: spelling fixes - hw/scsi/vhost-scsi: don't double close vhostfd on error - virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup - hw/scsi/vhost-scsi: don't leak vqs on error - hw/i386/pc: Add missing property descriptions - pcie_aer: Don't trigger a LSI if none are defined - pci: Export the pci_intx() function - hw/qdev: Cosmetic around documentation - tests/unit: fix a -Wformat-truncation warning - tests/avocado: mark ReplayKernelNormal.test_mips64el_malta as flaky - i386/sev: Avoid SEV-ES crash due to missing MSR_EFER_LMA bit - ui/vnc-clipboard: fix inflate_buffer - hw/usb/hcd-xhci.c: spelling: tranfer Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com> (cherry picked from commit 68fee7dc06a6beb5f69d951e22a7f16091f269ff)
50 lines
1.6 KiB
Diff
50 lines
1.6 KiB
Diff
From 69f5f16cee63b0d07ee612b59a0d125780c13bdb Mon Sep 17 00:00:00 2001
|
|
From: boringandboring <wangjinlei_yewu@cmss.chinamobile.com>
|
|
Date: Fri, 8 Dec 2023 09:13:42 +0800
|
|
Subject: [PATCH] hw/scsi/vhost-scsi: don't double close vhostfd on error
|
|
|
|
cherry picked from 539ba1acacb11a0f27a7e7ff7e2a7c1294e0a1ea
|
|
|
|
vhost_dev_init calls vhost_dev_cleanup on error, which closes vhostfd,
|
|
don't double close it.
|
|
|
|
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
|
|
Message-Id: <20211129132358.1110372-2-d-tatianin@yandex-team.ru>
|
|
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/scsi/vhost-scsi.c | 9 ++++++++-
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
|
|
index b0a9c45e43..5536cc8a88 100644
|
|
--- a/hw/scsi/vhost-scsi.c
|
|
+++ b/hw/scsi/vhost-scsi.c
|
|
@@ -220,6 +220,11 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
|
|
ret = vhost_dev_init(&vsc->dev, (void *)(uintptr_t)vhostfd,
|
|
VHOST_BACKEND_TYPE_KERNEL, 0, errp);
|
|
if (ret < 0) {
|
|
+ /*
|
|
+ * vhost_dev_init calls vhost_dev_cleanup on error, which closes
|
|
+ * vhostfd, don't double close it.
|
|
+ */
|
|
+ vhostfd = -1;
|
|
goto free_vqs;
|
|
}
|
|
|
|
@@ -240,7 +245,9 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
|
|
error_free(vsc->migration_blocker);
|
|
virtio_scsi_common_unrealize(dev);
|
|
close_fd:
|
|
- close(vhostfd);
|
|
+ if (vhostfd >= 0) {
|
|
+ close(vhostfd);
|
|
+ }
|
|
return;
|
|
}
|
|
|
|
--
|
|
2.27.0
|
|
|