qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/2] vhost-scsi: Call virtio_scsi_common_unrealize()


From: elohimes
Subject: [Qemu-devel] [PATCH 1/2] vhost-scsi: Call virtio_scsi_common_unrealize() when device realize failed
Date: Mon, 15 Jul 2019 18:23:25 +0800

From: Xie Yongji <address@hidden>

This avoids memory leak when device hotplug is failed.

Signed-off-by: Xie Yongji <address@hidden>
---
 hw/scsi/vhost-scsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 4090f99ee4..db4a090576 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, errp);
  close_fd:
     close(vhostfd);
     return;
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]