vhost: fix double free on device stop
PATCH 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.
Signed-off-by Michael S. Tsirkin <[email protected]>
--- hw/vhost.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
hw/vhost.c +4 -0
@@ -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 ; }
Signature · 1 line
1.7.5.53.gc233e
Quoted 6 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.
Signed-off-by Michael S. Tsirkin <[email protected]>
Um, this fixed double free but added another one.
Not sure why did it work for me :(
Sent a fixed v2
Quoted 20 lines
--- hw/vhost.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)hw/vhost.c +4
-0@@ -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 ; }Signature · 1 line
1.7.5.53.gc233e