qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: arei.gonglei@huawei.com
Cc: pbonzini@redhat.com, mst@redhat.com, qemu-devel@nongnu.org,
	peter.huangpeng@huawei.com
Subject: Re: [Qemu-devel] [PATCH] vhost: Fix vhostfd leak in error branch
Date: Mon, 01 Dec 2014 05:11:29 +0008	[thread overview]
Message-ID: <1417410209.4969.0@smtp.corp.redhat.com> (raw)
In-Reply-To: <1417166789-1960-1-git-send-email-arei.gonglei@huawei.com>



On Fri, Nov 28, 2014 at 5:26 PM, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  hw/scsi/vhost-scsi.c | 1 +
>  hw/virtio/vhost.c    | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
> index 308b393..dcb2bc5 100644
> --- a/hw/scsi/vhost-scsi.c
> +++ b/hw/scsi/vhost-scsi.c
> @@ -233,6 +233,7 @@ static void vhost_scsi_realize(DeviceState *dev, 
> Error **errp)
>                                 vhost_dummy_handle_output);
>      if (err != NULL) {
>          error_propagate(errp, err);
> +        close(vhostfd);
>          return;
>      }
>  
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 5d7c40a..5a12861 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -817,10 +817,12 @@ int vhost_dev_init(struct vhost_dev *hdev, void 
> *opaque,
>      int i, r;
>  
>      if (vhost_set_backend_type(hdev, backend_type) < 0) {
> +        close((uintptr_t)opaque);
>          return -1;
>      }
>  
>      if (hdev->vhost_ops->vhost_backend_init(hdev, opaque) < 0) {
> +        close((uintptr_t)opaque);
>          return -errno;
>      }
>  

Patch looks fine.

I wonder whether setting errno and goto fail would be better here?
This will let vhost_backend_cleanup() to do the cleanup, e.g closeing
fd or purging queue (for vhost uesr).

  reply	other threads:[~2014-12-01  5:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-28  9:26 [Qemu-devel] [PATCH] vhost: Fix vhostfd leak in error branch arei.gonglei
2014-12-01  5:03 ` Jason Wang [this message]
2014-12-01  6:27   ` Gonglei
2014-12-01  7:52     ` Jason Wang
2014-12-01  9:37 ` [Qemu-devel] [for-2.2] " Michael S. Tsirkin
2014-12-01 13:23   ` Peter Maydell

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=1417410209.4969.0@smtp.corp.redhat.com \
    --to=jasowang@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    /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).