diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2016-05-05 16:53:35 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-06-20 11:44:12 +0100 |
commit | f1d3b99154138741161fc52f5a8c373bf71613c6 (patch) | |
tree | 9b8dc89292f0f64c6151601192a12c0805bc3047 /tests/libqos/virtio-mmio.c | |
parent | c75f4c061bacad0c41708bf17d526fac72314ad0 (diff) |
libqos: add qvirtqueue_cleanup()
qvirtqueue_setup() allocates the vring and virtqueue state. So far
there has been no function to free it. Callers have been using
guest_free() for the vring but forgot to free the QVirtQueue state.
This patch solves the memory leak by introducing qvirtqueue_cleanup().
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/libqos/virtio-mmio.c')
-rw-r--r-- | tests/libqos/virtio-mmio.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/libqos/virtio-mmio.c b/tests/libqos/virtio-mmio.c index ccb92d9eef..0cab38f296 100644 --- a/tests/libqos/virtio-mmio.c +++ b/tests/libqos/virtio-mmio.c @@ -154,6 +154,13 @@ static QVirtQueue *qvirtio_mmio_virtqueue_setup(QVirtioDevice *d, return vq; } +static void qvirtio_mmio_virtqueue_cleanup(QVirtQueue *vq, + QGuestAllocator *alloc) +{ + guest_free(alloc, vq->desc); + g_free(vq); +} + static void qvirtio_mmio_virtqueue_kick(QVirtioDevice *d, QVirtQueue *vq) { QVirtioMMIODevice *dev = (QVirtioMMIODevice *)d; @@ -176,6 +183,7 @@ const QVirtioBus qvirtio_mmio = { .get_queue_size = qvirtio_mmio_get_queue_size, .set_queue_address = qvirtio_mmio_set_queue_address, .virtqueue_setup = qvirtio_mmio_virtqueue_setup, + .virtqueue_cleanup = qvirtio_mmio_virtqueue_cleanup, .virtqueue_kick = qvirtio_mmio_virtqueue_kick, }; |