qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 2/2] vhost-user-scsi: Call virtio_scsi_common


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2 2/2] vhost-user-scsi: Call virtio_scsi_common_unrealize() when device realize failed
Date: Wed, 17 Jul 2019 11:42:12 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2

On 17/07/19 02:46, address@hidden wrote:
> From: Xie Yongji <address@hidden>
> 
> This avoids memory leak when device hotplug is failed.
> 
> Signed-off-by: Xie Yongji <address@hidden>
> ---
>  hw/scsi/vhost-user-scsi.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
> index a9fd8ea305..17826ef8e2 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,23 @@ 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:
> +    err = NULL;
> +    virtio_scsi_common_unrealize(dev, &err);
> +    error_propagate(errp, err);
>  }
>  
>  static void vhost_user_scsi_unrealize(DeviceState *dev, Error **errp)
> 

Queued both patches, thanks.

Paolo



reply via email to

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