[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 51/52] hw/scsi/vhost-scsi: don't double close vhostfd on error
|
From: |
Michael S. Tsirkin |
|
Subject: |
[PULL 51/52] hw/scsi/vhost-scsi: don't double close vhostfd on error |
|
Date: |
Thu, 6 Jan 2022 08:18:44 -0500 |
From: Daniil Tatianin <d-tatianin@yandex-team.ru>
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>
---
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 efb3e14d9e..778f43e4c1 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -222,6 +222,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;
}
@@ -242,7 +247,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;
}
--
MST
- [PULL 43/52] acpi: fix QEMU crash when started with SLIC table, (continued)
- [PULL 43/52] acpi: fix QEMU crash when started with SLIC table, Michael S. Tsirkin, 2022/01/06
- [PULL 42/52] intel-iommu: correctly check passthrough during translation, Michael S. Tsirkin, 2022/01/06
- [PULL 45/52] tests: acpi: add SLIC table test, Michael S. Tsirkin, 2022/01/06
- [PULL 47/52] acpihp: simplify acpi_pcihp_disable_root_bus, Michael S. Tsirkin, 2022/01/06
- [PULL 32/52] util/oslib-posix: Don't create too many threads with small memory or little pages, Michael S. Tsirkin, 2022/01/06
- [PULL 49/52] docs: reSTify virtio-balloon-stats documentation and move to docs/interop, Michael S. Tsirkin, 2022/01/06
- [PULL 38/52] MAINTAINERS: Add a separate entry for acpi/VIOT tables, Michael S. Tsirkin, 2022/01/06
- [PULL 30/52] util/oslib-posix: Support MADV_POPULATE_WRITE for os_mem_prealloc(), Michael S. Tsirkin, 2022/01/06
- [PULL 48/52] hw/i386/pc: Add missing property descriptions, Michael S. Tsirkin, 2022/01/06
- [PULL 50/52] hw/scsi/vhost-scsi: don't leak vqs on error, Michael S. Tsirkin, 2022/01/06
- [PULL 51/52] hw/scsi/vhost-scsi: don't double close vhostfd on error,
Michael S. Tsirkin <=
- [PULL 52/52] virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup, Michael S. Tsirkin, 2022/01/06
- [PULL 44/52] tests: acpi: whitelist expected blobs before changing them, Michael S. Tsirkin, 2022/01/06
- [PULL 04/52] virtio-pci: decouple notifier from interrupt process, Michael S. Tsirkin, 2022/01/06
- Re: [PULL 00/52] virtio,pci,pc: features,fixes,cleanups, Richard Henderson, 2022/01/06