Skip to contentSkip to conversation

vhost/scsi: call vhost_dev_cleanup() at unrealize() time

PATCH Applied Igor Mammedov 2 participants 2 messages Jul 30, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost/scsi: call vhost_dev_cleanup() at unrealize() time

vhost-scsi calls vhost_dev_init() at realize() time but forgets to call it's counterpart vhost_dev_cleanup() at unrealize() time.

Calling it should fix leaking of memory table and mem_sections table in vhost device. And also unregister vhost's memory listerner to prevent access from memory core to freed memory.

---
 hw/scsi/vhost-scsi.c | 1 +
 1 file changed, 1 insertion(+)
hw/scsi/vhost-scsi.c +1 -0
index a69918b..0dd57ff 100644
@@ -277,6 +277,7 @@ static void vhost_scsi_unrealize(DeviceState *dev, Error **errp)
     /* This will stop vhost backend. */
     vhost_scsi_set_status(vdev, 0);
 
+    vhost_dev_cleanup(&s->dev);
     g_free(s->dev.vqs);
 
     virtio_scsi_common_unrealize(dev, errp);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 20 lines · Igor Mammedov

vhost-scsi calls vhost_dev_init() at realize() time but forgets to call it's counterpart vhost_dev_cleanup() at unrealize() time.

Calling it should fix leaking of memory table and mem_sections table in vhost device. And also unregister vhost's memory listerner to prevent access from memory core to freed memory.

---
 hw/scsi/vhost-scsi.c | 1 +
 1 file changed, 1 insertion(+)
hw/scsi/vhost-scsi.c +0 -0
index a69918b..0dd57ff 100644

hw/scsi/vhost-scsi.c static void vhost_scsi_unrealize(DeviceState *dev, Error **errp) · line 283

Quoted 7 lines
hw/scsi/vhost-scsi.c +1 -0
@@ -277,6 +277,7 @@ static void vhost_scsi_unrealize(DeviceState *dev, Error **errp)
     /* This will stop vhost backend. */
     vhost_scsi_set_status(vdev, 0);
 
+    vhost_dev_cleanup(&s->dev);
     g_free(s->dev.vqs);
 
     virtio_scsi_common_unrealize(dev, errp);

Applied to scsi-next, thanks.

Paolo