diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2017-02-07 16:55:14 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2017-03-01 11:58:57 +0400 |
commit | 80e1eea37a25a7696137e680285e36d0bfdc9f34 (patch) | |
tree | ddd94260713176d1eecf691881f3dba3d3fb6bcd /tests/virtio-blk-test.c | |
parent | c4523aae0664aecaa366d45e3d0f3d810ca33062 (diff) |
tests: fix virtio-blk-test leaks
Use qvirtio_pci_device_find_slot() to avoid leaking the non-hp
device. Add assert() to avoid further leaks in the future.
Use qvirtio_pci_device_free() to correctly free QVirtioPCIDevice.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests/virtio-blk-test.c')
-rw-r--r-- | tests/virtio-blk-test.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 10a92b410a..1eee95df49 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -108,7 +108,7 @@ static QVirtioPCIDevice *virtio_blk_pci_init(QPCIBus *bus, int slot) { QVirtioPCIDevice *dev; - dev = qvirtio_pci_device_find(bus, VIRTIO_ID_BLOCK); + dev = qvirtio_pci_device_find_slot(bus, VIRTIO_ID_BLOCK, slot); g_assert(dev != NULL); g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_BLOCK); g_assert_cmphex(dev->pdev->devfn, ==, ((slot << 3) | PCI_FN)); @@ -296,7 +296,7 @@ static void pci_basic(void) /* End test */ qvirtqueue_cleanup(dev->vdev.bus, &vqpci->vq, qs->alloc); qvirtio_pci_device_disable(dev); - g_free(dev); + qvirtio_pci_device_free(dev); qtest_shutdown(qs); } @@ -389,7 +389,7 @@ static void pci_indirect(void) /* End test */ qvirtqueue_cleanup(dev->vdev.bus, &vqpci->vq, qs->alloc); qvirtio_pci_device_disable(dev); - g_free(dev); + qvirtio_pci_device_free(dev); qtest_shutdown(qs); } @@ -418,7 +418,7 @@ static void pci_config(void) g_assert_cmpint(capacity, ==, n_size / 512); qvirtio_pci_device_disable(dev); - g_free(dev); + qvirtio_pci_device_free(dev); qtest_shutdown(qs); } @@ -526,7 +526,7 @@ static void pci_msix(void) qvirtqueue_cleanup(dev->vdev.bus, &vqpci->vq, qs->alloc); qpci_msix_disable(dev->pdev); qvirtio_pci_device_disable(dev); - g_free(dev); + qvirtio_pci_device_free(dev); qtest_shutdown(qs); } @@ -642,7 +642,7 @@ static void pci_idx(void) qvirtqueue_cleanup(dev->vdev.bus, &vqpci->vq, qs->alloc); qpci_msix_disable(dev->pdev); qvirtio_pci_device_disable(dev); - g_free(dev); + qvirtio_pci_device_free(dev); qtest_shutdown(qs); } @@ -661,7 +661,7 @@ static void pci_hotplug(void) dev = virtio_blk_pci_init(qs->pcibus, PCI_SLOT_HP); g_assert(dev); qvirtio_pci_device_disable(dev); - g_free(dev); + qvirtio_pci_device_free(dev); /* unplug secondary disk */ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { |