[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 26/28] tests: fix usb-test leaks
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PULL 26/28] tests: fix usb-test leaks |
Date: |
Wed, 1 Mar 2017 13:04:51 +0400 |
Fix the usb tests leaks.
Spotted by ASAN.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Gerd Hoffmann <address@hidden>
---
tests/libqos/usb.h | 1 +
tests/libqos/usb.c | 5 +++++
tests/usb-hcd-ehci-test.c | 10 ++++++++++
tests/usb-hcd-uhci-test.c | 1 +
4 files changed, 17 insertions(+)
diff --git a/tests/libqos/usb.h b/tests/libqos/usb.h
index 423dcfd82f..297cfc564d 100644
--- a/tests/libqos/usb.h
+++ b/tests/libqos/usb.h
@@ -11,6 +11,7 @@ struct qhc {
void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc,
uint32_t devfn, int bar);
void uhci_port_test(struct qhc *hc, int port, uint16_t expect);
+void uhci_deinit(struct qhc *hc);
void usb_test_hotplug(const char *bus_name, const int port,
void (*port_check)(void));
diff --git a/tests/libqos/usb.c b/tests/libqos/usb.c
index 98408d93f3..0cdfaecda7 100644
--- a/tests/libqos/usb.c
+++ b/tests/libqos/usb.c
@@ -24,6 +24,11 @@ void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc,
uint32_t devfn, int bar)
hc->bar = qpci_iomap(hc->dev, bar, NULL);
}
+void uhci_deinit(struct qhc *hc)
+{
+ g_free(hc->dev);
+}
+
void uhci_port_test(struct qhc *hc, int port, uint16_t expect)
{
uint16_t value = qpci_io_readw(hc->dev, hc->bar, 0x10 + 2 * port);
diff --git a/tests/usb-hcd-ehci-test.c b/tests/usb-hcd-ehci-test.c
index fba84b4bee..944eb1c088 100644
--- a/tests/usb-hcd-ehci-test.c
+++ b/tests/usb-hcd-ehci-test.c
@@ -61,6 +61,15 @@ static void test_init(void)
qusb_pci_init_one(pcibus, &ehci1, QPCI_DEVFN(0x1d, 7), 0);
}
+static void test_deinit(void)
+{
+ uhci_deinit(&uhci1);
+ uhci_deinit(&uhci2);
+ uhci_deinit(&uhci3);
+ uhci_deinit(&ehci1);
+ qpci_free_pc(pcibus);
+}
+
static void pci_uhci_port_1(void)
{
g_assert(pcibus != NULL);
@@ -161,6 +170,7 @@ int main(int argc, char **argv)
test_init();
ret = g_test_run();
+ test_deinit();
qtest_end();
diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c
index e956b9ccb7..f25bae5e6c 100644
--- a/tests/usb-hcd-uhci-test.c
+++ b/tests/usb-hcd-uhci-test.c
@@ -28,6 +28,7 @@ static void test_port(int port)
g_assert(port > 0);
qusb_pci_init_one(qs->pcibus, &uhci, QPCI_DEVFN(0x1d, 0), 4);
uhci_port_test(&uhci, port - 1, UHCI_PORT_CCS);
+ uhci_deinit(&uhci);
}
static void test_port_1(void)
--
2.12.0.rc2.3.gc93709801
- [Qemu-devel] [PULL 16/28] tests: fix eepro100-test leak, (continued)
- [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
- [Qemu-devel] [PULL 20/28] tests: fix e1000e leaks, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 21/28] tests: fix virtio-scsi-test leak, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 22/28] tests: fix virtio-9p-test leaks, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 23/28] bus: do not unref hotplug handler, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 24/28] usb: release the created buses, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 25/28] tests: allows to run single test in usb-hcd-ehci-test, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 26/28] tests: fix usb-test leaks,
Marc-André Lureau <=
- [Qemu-devel] [PULL 27/28] tests: add specialized device_find function, Marc-André Lureau, 2017/03/01
- [Qemu-devel] [PULL 28/28] tests: fix virtio-blk-test leaks, Marc-André Lureau, 2017/03/01
- Re: [Qemu-devel] [PULL 00/28] Leak patches, Peter Maydell, 2017/03/02