qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: elohimes@gmail.com, mst@redhat.com, stefanha@gmail.com, fam@euphon.net
Cc: Xie Yongji <xieyongji@baidu.com>, qemu-devel@nongnu.org
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	[thread overview]
Message-ID: <40851745-e228-4837-63fc-afd68455fb55@redhat.com> (raw)
In-Reply-To: <20190717004606.12444-2-xieyongji@baidu.com>

On 17/07/19 02:46, elohimes@gmail.com wrote:
> From: Xie Yongji <xieyongji@baidu.com>
> 
> This avoids memory leak when device hotplug is failed.
> 
> Signed-off-by: Xie Yongji <xieyongji@baidu.com>
> ---
>  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	other threads:[~2019-07-17  9:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17  0:46 [Qemu-devel] [PATCH v2 1/2] vhost-scsi: Call virtio_scsi_common_unrealize() when device realize failed elohimes
2019-07-17  0:46 ` [Qemu-devel] [PATCH v2 2/2] vhost-user-scsi: " elohimes
2019-07-17  9:42   ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40851745-e228-4837-63fc-afd68455fb55@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=elohimes@gmail.com \
    --cc=fam@euphon.net \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=xieyongji@baidu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).