Skip to contentSkip to conversation

vhost: fix double free on device stop

PATCH In review Michael S. Tsirkin 3 participants 3 messages Jun 21, 2011 – Jun 22, 2011

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 vhost: fix double free on device stop

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.

---
 hw/vhost.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
hw/vhost.c +1 -0
index 80f771e..c3d8821 100644
@@ -784,5 +784,6 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)
 
     hdev->started = false;
     qemu_free(hdev->log);
+    hdev->log = NULL;
     hdev->log_size = 0;
 }
Signature · 1 line
1.7.5.53.gc233e
Acked-by on v2 1/1
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin

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.

---

Quoted 14 lines
  hw/vhost.c |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
hw/vhost.c +1 -0
index 80f771e..c3d8821 100644
@@ -784,5 +784,6 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)
 
      hdev->started = false;
      qemu_free(hdev->log);
+    hdev->log = NULL;
      hdev->log_size = 0;
  }