qemu/hw-scsi-vhost-scsi-don-t-leak-vqs-on-error.patch
Jiabo Feng 999512f123 QEMU update to version 6.2.0-87(master)
- 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)
2023-12-22 15:12:17 +08:00

56 lines
1.9 KiB
Diff

From ad55425ad09197b443c150828ac16dbf4242141f Mon Sep 17 00:00:00 2001
From: boringandboring <wangjinlei_yewu@cmss.chinamobile.com>
Date: Thu, 7 Dec 2023 19:45:33 +0800
Subject: [PATCH] hw/scsi/vhost-scsi: don't leak vqs on error
cherry picked from b259772afc29ef6af4e911d8e695dd7e2ed31066
vhost_dev_init calls vhost_dev_cleanup in case of an error during
initialization, which zeroes out the entire vsc->dev as well as the
vsc->dev.vqs pointer. This prevents us from properly freeing it in free_vqs.
Keep a local copy of the pointer so we can free it later.
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Message-Id: <20211129132358.1110372-1-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 | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index b0a9c45e43..2fbc7f039d 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -170,6 +170,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
Error *err = NULL;
int vhostfd = -1;
int ret;
+ struct vhost_virtqueue *vqs = NULL;
if (!vs->conf.wwpn) {
error_setg(errp, "vhost-scsi: missing wwpn");
@@ -213,7 +214,8 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
}
vsc->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
- vsc->dev.vqs = g_new0(struct vhost_virtqueue, vsc->dev.nvqs);
+ vqs = g_new0(struct vhost_virtqueue, vsc->dev.nvqs);
+ vsc->dev.vqs = vqs;
vsc->dev.vq_index = 0;
vsc->dev.backend_features = 0;
@@ -232,7 +234,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
return;
free_vqs:
- g_free(vsc->dev.vqs);
+ g_free(vqs);
if (!vsc->migratable) {
migrate_del_blocker(vsc->migration_blocker);
}
--
2.27.0