]> git.proxmox.com Git - mirror_qemu.git/commitdiff
virtio: Free blk virqueues at unrealize()
authorEugenio Pérez <eperezma@redhat.com>
Fri, 25 Oct 2019 08:35:22 +0000 (10:35 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 25 Oct 2019 11:46:22 +0000 (07:46 -0400)
The function virtio_del_queue was not called at unrealize() callback.

This was detected due to add an allocated element on the vq introduce
in future commits (used_elems) and running address sanitizer memory
leak detector.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Message-Id: <20191025083527.30803-4-eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/block/virtio-blk.c

index ed2ddebd2bc124b86a62e83ec12c0b55c1c56bd2..ba846fe9dc61891aa9f45ea81fd00250089cf829 100644 (file)
@@ -1206,9 +1206,14 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIOBlock *s = VIRTIO_BLK(dev);
+    VirtIOBlkConf *conf = &s->conf;
+    unsigned i;
 
     virtio_blk_data_plane_destroy(s->dataplane);
     s->dataplane = NULL;
+    for (i = 0; i < conf->num_queues; i++) {
+        virtio_del_queue(vdev, i);
+    }
     qemu_del_vm_change_state_handler(s->change);
     blockdev_mark_auto_del(s->blk);
     virtio_cleanup(vdev);