qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org, Jason Wang <jasowang@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	Jes.Sorensen@redhat.com
Subject: Re: [Qemu-devel] [PATCH] vhost: fix double free on device stop
Date: Tue, 21 Jun 2011 20:40:33 +0300	[thread overview]
Message-ID: <20110621174033.GB17410@redhat.com> (raw)
In-Reply-To: <20110621171044.GA16869@redhat.com>

On Tue, Jun 21, 2011 at 08:10:44PM +0300, Michael S. Tsirkin wrote:
> vhost dev stop failed to clear the log field.
> Typically not an issue as dev start overwrites this field,
> but if logging gets disabled before the following start,
> it doesn't so this causes a double free.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Um, this fixed double free but added another one.
Not sure why did it work for me :(
Sent a fixed v2

> ---
>  hw/vhost.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/vhost.c b/hw/vhost.c
> index 80f771e..1fbf2e5 100644
> --- a/hw/vhost.c
> +++ b/hw/vhost.c
> @@ -784,5 +784,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)
>  
>      hdev->started = false;
>      qemu_free(hdev->log);
> +    if (hdev->log) {
> +        qemu_free(hdev->log);
> +    }
> +    hdev->log = NULL;
>      hdev->log_size = 0;
>  }
> -- 
> 1.7.5.53.gc233e

      reply	other threads:[~2011-06-21 17:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-21 17:10 [Qemu-devel] [PATCH] vhost: fix double free on device stop Michael S. Tsirkin
2011-06-21 17:40 ` Michael S. Tsirkin [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=20110621174033.GB17410@redhat.com \
    --to=mst@redhat.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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).