qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vhost: fix double free on device stop
@ 2011-06-21 17:10 Michael S. Tsirkin
  2011-06-21 17:40 ` Michael S. Tsirkin
  0 siblings, 1 reply; 2+ messages in thread
From: Michael S. Tsirkin @ 2011-06-21 17:10 UTC (permalink / raw)
  To: qemu-devel, Jason Wang, Juan Quintela, Jes.Sorensen

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>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] vhost: fix double free on device stop
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2011-06-21 17:40 UTC (permalink / raw)
  To: qemu-devel, Jason Wang, Juan Quintela, Jes.Sorensen

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-21 17:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).