diff --git a/tests/libqos/usb.c b/tests/libqos/usb.c index 98408d93f3c10242d8b097ba4b9a2953f528348c..0cdfaecda7f418a6c824696fa9648b523e41351e 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/libqos/usb.h b/tests/libqos/usb.h index 423dcfd82fdfffd16f9e81caf5fb1125981e2f75..297cfc564dbea31fa166d5339bd6aaa46ae912b5 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/usb-hcd-ehci-test.c b/tests/usb-hcd-ehci-test.c index fba84b4bee88cc430100a11b588397272aff65b2..944eb1c088b9b502d61d9443018f09d350abf81b 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 e956b9ccb7a6a2155d3a4badcb07828237a85f36..f25bae5e6c1e1f7b6837e4924e34c98420619112 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)