[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/12] vhost-user-scsi: Call virtio_scsi_common_unrea
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 05/12] vhost-user-scsi: Call virtio_scsi_common_unrealize() when device realize failed |
Date: |
Sat, 20 Jul 2019 17:18:39 +0200 |
From: Xie Yongji <address@hidden>
This avoids memory leak when device hotplug is failed.
Signed-off-by: Xie Yongji <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi/vhost-user-scsi.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index a0b69fb..fcee67d 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -87,7 +87,7 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error
**errp)
}
if (!vhost_user_init(&s->vhost_user, &vs->conf.chardev, errp)) {
- return;
+ goto free_virtio;
}
vsc->dev.nvqs = 2 + vs->conf.num_queues;
@@ -101,15 +101,21 @@ static void vhost_user_scsi_realize(DeviceState *dev,
Error **errp)
if (ret < 0) {
error_setg(errp, "vhost-user-scsi: vhost initialization failed: %s",
strerror(-ret));
- vhost_user_cleanup(&s->vhost_user);
- g_free(vqs);
- return;
+ goto free_vhost;
}
/* Channel and lun both are 0 for bootable vhost-user-scsi disk */
vsc->channel = 0;
vsc->lun = 0;
vsc->target = vs->conf.boot_tpgt;
+
+ return;
+
+free_vhost:
+ vhost_user_cleanup(&s->vhost_user);
+ g_free(vqs);
+free_virtio:
+ virtio_scsi_common_unrealize(dev);
}
static void vhost_user_scsi_unrealize(DeviceState *dev, Error **errp)
--
1.8.3.1
- [Qemu-devel] [PULL 00/12] Misc patches for QEMU 4.0-rc2, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 01/12] target/i386: kvm: Demand nested migration kernel capabilities only when vCPU may have enabled VMX, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 02/12] target/i386: skip KVM_GET/SET_NESTED_STATE if VMX disabled, or for SVM, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 03/12] virtio-scsi: remove unused argument to virtio_scsi_common_realize, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 04/12] vhost-scsi: Call virtio_scsi_common_unrealize() when device realize failed, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 05/12] vhost-user-scsi: Call virtio_scsi_common_unrealize() when device realize failed,
Paolo Bonzini <=
- [Qemu-devel] [PULL 06/12] scsi-generic: Check sense key before request snooping and patching, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 07/12] test-bitmap: add test for bitmap_set, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 09/12] qmp: don't emit the RESET event on wakeup, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 08/12] hmp: Print if memory section is registered with an accelerator, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 11/12] i386: indicate that 'pconfig' feature was removed intentionally, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 12/12] target/i386: sev: fix failed message typos, Paolo Bonzini, 2019/07/20
- [Qemu-devel] [PULL 10/12] build-sys: do no support modules on Windows, Paolo Bonzini, 2019/07/20
- Re: [Qemu-devel] [PULL 00/12] Misc patches for QEMU 4.0-rc2, Peter Maydell, 2019/07/22