diff mbox

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

Message ID 1438262999-287627-1-git-send-email-imammedo@redhat.com
State New
Headers show

Commit Message

Igor Mammedov July 30, 2015, 1:29 p.m. UTC
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.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/scsi/vhost-scsi.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Paolo Bonzini July 30, 2015, 1:51 p.m. UTC | #1
On 30/07/2015 15:29, Igor Mammedov wrote:
> 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.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  hw/scsi/vhost-scsi.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
> index a69918b..0dd57ff 100644
> --- a/hw/scsi/vhost-scsi.c
> +++ b/hw/scsi/vhost-scsi.c
> @@ -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
diff mbox

Patch

diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index a69918b..0dd57ff 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -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);