[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 51/55] hw/scsi/vhost-scsi: don't double close vhostfd on error
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 51/55] hw/scsi/vhost-scsi: don't double close vhostfd on error |
Date: |
Fri, 7 Jan 2022 06:05:37 -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 v2 42/55] intel-iommu: correctly check passthrough during translation, (continued)
- [PULL v2 42/55] intel-iommu: correctly check passthrough during translation, Michael S. Tsirkin, 2022/01/07
- [PULL v2 47/55] acpihp: simplify acpi_pcihp_disable_root_bus, Michael S. Tsirkin, 2022/01/07
- [PULL v2 37/55] virtio: signal after wrapping packed used_idx, Michael S. Tsirkin, 2022/01/07
- [PULL v2 50/55] hw/scsi/vhost-scsi: don't leak vqs on error, Michael S. Tsirkin, 2022/01/07
- [PULL v2 39/55] linux-headers: sync VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, Michael S. Tsirkin, 2022/01/07
- [PULL v2 44/55] tests: acpi: whitelist expected blobs before changing them, Michael S. Tsirkin, 2022/01/07
- [PULL v2 45/55] tests: acpi: add SLIC table test, Michael S. Tsirkin, 2022/01/07
- [PULL v2 53/55] tests: acpi: prepare for updated TPM related tables, Michael S. Tsirkin, 2022/01/07
- [PULL v2 46/55] tests: acpi: SLIC: update expected blobs, Michael S. Tsirkin, 2022/01/07
- [PULL v2 38/55] MAINTAINERS: Add a separate entry for acpi/VIOT tables, Michael S. Tsirkin, 2022/01/07
- [PULL v2 51/55] hw/scsi/vhost-scsi: don't double close vhostfd on error,
Michael S. Tsirkin <=
- [PULL v2 52/55] virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup, Michael S. Tsirkin, 2022/01/07
- [PULL v2 48/55] hw/i386/pc: Add missing property descriptions, Michael S. Tsirkin, 2022/01/07
- [PULL v2 49/55] docs: reSTify virtio-balloon-stats documentation and move to docs/interop, Michael S. Tsirkin, 2022/01/07
- [PULL v2 54/55] acpi: tpm: Add missing device identification objects, Michael S. Tsirkin, 2022/01/07
- [PULL v2 55/55] tests: acpi: Add updated TPM related tables, Michael S. Tsirkin, 2022/01/07
- Re: [PULL v2 00/55] virtio,pci,pc: features,fixes,cleanups, Richard Henderson, 2022/01/07