From 934443c37befc9e268f5c661cb9552a2ee572e19 Mon Sep 17 00:00:00 2001 From: Xie Yongji Date: Wed, 17 Jul 2019 08:46:05 +0800 Subject: vhost-scsi: Call virtio_scsi_common_unrealize() when device realize failed This avoids memory leak when device hotplug is failed. Signed-off-by: Xie Yongji Message-Id: <20190717004606.12444-1-xieyongji@baidu.com> Signed-off-by: Paolo Bonzini --- hw/scsi/vhost-scsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 76bb875..343ca8b 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -210,7 +210,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) if (err) { error_propagate(errp, err); error_free(vsc->migration_blocker); - goto close_fd; + goto free_virtio; } } @@ -240,6 +240,8 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) migrate_del_blocker(vsc->migration_blocker); } g_free(vsc->dev.vqs); + free_virtio: + virtio_scsi_common_unrealize(dev); close_fd: close(vhostfd); return; -- cgit v1.1