summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-02-06 08:56:15 +0000
committerMarc-André Lureau <marcandre.lureau@redhat.com>2017-03-01 11:51:28 +0400
commit448fe3c1349b540c66e048788dd98b9c80775c53 (patch)
treee20b71581335ac73237e76dac7d06db1c92fb1d0
parent1bab33ab4ab4702f53012551cad333beb270f30d (diff)
downloadfocaccia-qemu-448fe3c1349b540c66e048788dd98b9c80775c53.tar.gz
focaccia-qemu-448fe3c1349b540c66e048788dd98b9c80775c53.zip
tests: fix e1000e leaks
Spotted by ASAN.

This hunk adds an assertion. It checks that we're finding no more than
one e1000e device: each hit allocates, but there is only one g_free().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r--tests/e1000e-test.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/e1000e-test.c b/tests/e1000e-test.c
index 8c42ca919f..c612dc64ec 100644
--- a/tests/e1000e-test.c
+++ b/tests/e1000e-test.c
@@ -99,7 +99,10 @@ static QPCIBus *test_bus;
 
 static void e1000e_pci_foreach_callback(QPCIDevice *dev, int devfn, void *data)
 {
-    *(QPCIDevice **) data = dev;
+    QPCIDevice **res = data;
+
+    g_assert_null(*res);
+    *res = dev;
 }
 
 static QPCIDevice *e1000e_device_find(QPCIBus *bus)
@@ -403,6 +406,7 @@ static void data_test_clear(e1000e_device *d)
     e1000e_device_clear(test_bus, d);
     close(test_sockets[0]);
     pc_alloc_uninit(test_alloc);
+    g_free(d->pci_dev);
     qpci_free_pc(test_bus);
     qtest_end();
 }