[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 3/9] virtio: Free rng and blk virqueues
From: |
Eugenio Pérez |
Subject: |
[PATCH v6 3/9] virtio: Free rng and blk virqueues |
Date: |
Thu, 24 Oct 2019 19:14:00 +0200 |
The function virtio_del_queue was not called at these devices
unrealize() callbacks.
This was detected due to add an allocated element on the next commit
(used_elems) and running address sanitizer memory leak detector.
Signed-off-by: Eugenio Pérez <address@hidden>
---
hw/block/virtio-blk.c | 5 +++++
hw/virtio/virtio-rng.c | 1 +
2 files changed, 6 insertions(+)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index ed2ddebd2b..ba846fe9dc 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);
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index e93bed020f..b498a20332 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -238,6 +238,7 @@ static void virtio_rng_device_unrealize(DeviceState *dev,
Error **errp)
qemu_del_vm_change_state_handler(vrng->vmstate);
timer_del(vrng->rate_limit_timer);
timer_free(vrng->rate_limit_timer);
+ virtio_del_queue(vdev, 0);
virtio_cleanup(vdev);
}
--
2.16.5
- [PATCH v6 0/9] Packed virtqueue for virtio, Eugenio Pérez, 2019/10/24
- [PATCH v6 1/9] virtio: basic structure for packed ring, Eugenio Pérez, 2019/10/24
- [PATCH v6 7/9] virtio: add property to enable packed virtqueue, Eugenio Pérez, 2019/10/24
- [PATCH v6 5/9] virtio: event suppression support for packed ring, Eugenio Pérez, 2019/10/24
- [PATCH v6 4/9] virtio: basic packed virtqueue support, Eugenio Pérez, 2019/10/24
- [PATCH v6 6/9] vhost_net: enable packed ring support, Eugenio Pérez, 2019/10/24
- [PATCH v6 3/9] virtio: Free rng and blk virqueues,
Eugenio Pérez <=
- [PATCH v6 2/9] virtio: device/driver area size calculation refactor for split ring, Eugenio Pérez, 2019/10/24
- [PATCH v6 8/9] virtio: add some rcu comments, Eugenio Pérez, 2019/10/24
- [PATCH v6 9/9] virtio: Move vdev->broken check to dispatch drop_all, Eugenio Pérez, 2019/10/24
- Re: [PATCH v6 0/9] Packed virtqueue for virtio, Jason Wang, 2019/10/24