[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 51/55] hw/scsi/vhost-scsi: don't double close vhostfd on error
|
From: |
Michael S. Tsirkin |
|
Subject: |
[PULL v3 51/55] hw/scsi/vhost-scsi: don't double close vhostfd on error |
|
Date: |
Fri, 7 Jan 2022 20:06:21 -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 v3 41/55] virtio-mem: Set "unplugged-inaccessible=auto" for the 7.0 machine on x86, (continued)
- [PULL v3 41/55] virtio-mem: Set "unplugged-inaccessible=auto" for the 7.0 machine on x86, Michael S. Tsirkin, 2022/01/07
- [PULL v3 42/55] intel-iommu: correctly check passthrough during translation, Michael S. Tsirkin, 2022/01/07
- [PULL v3 43/55] acpi: fix QEMU crash when started with SLIC table, Michael S. Tsirkin, 2022/01/07
- [PULL v3 44/55] tests: acpi: whitelist expected blobs before changing them, Michael S. Tsirkin, 2022/01/07
- [PULL v3 45/55] tests: acpi: add SLIC table test, Michael S. Tsirkin, 2022/01/07
- [PULL v3 46/55] tests: acpi: SLIC: update expected blobs, Michael S. Tsirkin, 2022/01/07
- [PULL v3 47/55] acpihp: simplify acpi_pcihp_disable_root_bus, Michael S. Tsirkin, 2022/01/07
- [PULL v3 48/55] hw/i386/pc: Add missing property descriptions, Michael S. Tsirkin, 2022/01/07
- [PULL v3 49/55] docs: reSTify virtio-balloon-stats documentation and move to docs/interop, Michael S. Tsirkin, 2022/01/07
- [PULL v3 50/55] hw/scsi/vhost-scsi: don't leak vqs on error, Michael S. Tsirkin, 2022/01/07
- [PULL v3 51/55] hw/scsi/vhost-scsi: don't double close vhostfd on error,
Michael S. Tsirkin <=
- [PULL v3 52/55] virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup, Michael S. Tsirkin, 2022/01/07
- [PULL v3 53/55] tests: acpi: prepare for updated TPM related tables, Michael S. Tsirkin, 2022/01/07
- [PULL v3 54/55] acpi: tpm: Add missing device identification objects, Michael S. Tsirkin, 2022/01/07
- [PULL v3 55/55] tests: acpi: Add updated TPM related tables, Michael S. Tsirkin, 2022/01/07
- Re: [PULL v3 00/55] virtio,pci,pc: features,fixes,cleanups, Richard Henderson, 2022/01/08