From: Eugenio Pérez Date: Fri, 25 Oct 2019 08:35:22 +0000 (+0200) Subject: virtio: Free blk virqueues at unrealize() X-Git-Tag: v4.2.0-rc0~32^2~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4a0117cf6e04d568a1963540bc0fa133b4d09b33;p=thirdparty%2Fqemu.git virtio: Free blk virqueues at unrealize() 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 Message-Id: <20191025083527.30803-4-eperezma@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index ed2ddebd2bc..ba846fe9dc6 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -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);