[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/28] tests: fix vhost-user-test leaks
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PULL 09/28] tests: fix vhost-user-test leaks |
Date: |
Wed, 1 Mar 2017 13:04:34 +0400 |
Spotted by ASAN.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
tests/libqos/virtio-pci.h | 2 ++
tests/libqos/virtio-pci.c | 6 ++++++
tests/vhost-user-test.c | 11 +++++++----
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/tests/libqos/virtio-pci.h b/tests/libqos/virtio-pci.h
index 38c54c63ea..0fab916cf8 100644
--- a/tests/libqos/virtio-pci.h
+++ b/tests/libqos/virtio-pci.h
@@ -34,6 +34,8 @@ extern const QVirtioBus qvirtio_pci;
void qvirtio_pci_foreach(QPCIBus *bus, uint16_t device_type,
void (*func)(QVirtioDevice *d, void *data), void *data);
QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type);
+void qvirtio_pci_device_free(QVirtioPCIDevice *dev);
+
void qvirtio_pci_device_enable(QVirtioPCIDevice *d);
void qvirtio_pci_device_disable(QVirtioPCIDevice *d);
diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index d4bf841f23..456cccdc7b 100644
--- a/tests/libqos/virtio-pci.c
+++ b/tests/libqos/virtio-pci.c
@@ -27,6 +27,12 @@ typedef struct QVirtioPCIForeachData {
void *user_data;
} QVirtioPCIForeachData;
+void qvirtio_pci_device_free(QVirtioPCIDevice *dev)
+{
+ g_free(dev->pdev);
+ g_free(dev);
+}
+
static QVirtioPCIDevice *qpcidevice_to_qvirtiodevice(QPCIDevice *pdev)
{
QVirtioPCIDevice *vpcidev;
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 2c45c7b29f..a61896c32d 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -139,6 +139,7 @@ enum {
};
typedef struct TestServer {
+ QPCIBus *bus;
gchar *socket_path;
gchar *mig_path;
gchar *chr_name;
@@ -160,14 +161,13 @@ static const char *root;
static void init_virtio_dev(TestServer *s)
{
- QPCIBus *bus;
QVirtioPCIDevice *dev;
uint32_t features;
- bus = qpci_init_pc(NULL);
- g_assert_nonnull(bus);
+ s->bus = qpci_init_pc(NULL);
+ g_assert_nonnull(s->bus);
- dev = qvirtio_pci_device_find(bus, VIRTIO_ID_NET);
+ dev = qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET);
g_assert_nonnull(dev);
qvirtio_pci_device_enable(dev);
@@ -180,6 +180,7 @@ static void init_virtio_dev(TestServer *s)
qvirtio_set_features(&dev->vdev, features);
qvirtio_set_driver_ok(&dev->vdev);
+ qvirtio_pci_device_free(dev);
}
static void wait_for_fds(TestServer *s)
@@ -507,6 +508,8 @@ static gboolean _test_server_free(TestServer *server)
g_free(server->mig_path);
g_free(server->chr_name);
+ qpci_free_pc(server->bus);
+
g_free(server);
return FALSE;
--
2.12.0.rc2.3.gc93709801
- [Qemu-devel] [PULL 00/28] Leak patches, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 01/28] qtest: fix a memory leak, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 02/28] tests: fix qmp response leak, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 03/28] tests: fix leaks in test-io-channel-command, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 04/28] timer: use an inline function for free, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 05/28] glib-compat: add g_test_add_data_func_full fallback, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 06/28] tests: fix ptimer leaks, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 07/28] tests: fix endianness-test leaks, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 08/28] tests: fix q35-test leaks, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 09/28] tests: fix vhost-user-test leaks,
Marc-André Lureau <=
- [Qemu-devel] [PULL 10/28] tests: fix ide-test leaks, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 12/28] tests: fix bios-tables-test leak, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 11/28] tests: fix hd-geo-test leaks, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 13/28] tests: fix ipmi-kcs-test leak, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 14/28] tests: fix ipmi-bt-test leak, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 15/28] pc: pcihp: avoid adding ACPI_PCIHP_PROP_BSEL twice, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 16/28] tests: fix eepro100-test leak, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 18/28] tests: fix e1000-test leak, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 17/28] tests: fix tco-test leaks, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 19/28] tests: fix i440fx-test leaks, Marc-André Lureau, 2017/03/01