提交 62030ed1 编写于 作者: M Marc-André Lureau

tests: fix usb-test leaks

Fix the usb tests leaks.

Spotted by ASAN.
Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: NGerd Hoffmann <kraxel@redhat.com>
上级 d3510ff9
...@@ -24,6 +24,11 @@ void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc, uint32_t devfn, int bar) ...@@ -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); 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) 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); uint16_t value = qpci_io_readw(hc->dev, hc->bar, 0x10 + 2 * port);
......
...@@ -11,6 +11,7 @@ struct qhc { ...@@ -11,6 +11,7 @@ struct qhc {
void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc, void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc,
uint32_t devfn, int bar); uint32_t devfn, int bar);
void uhci_port_test(struct qhc *hc, int port, uint16_t expect); 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 usb_test_hotplug(const char *bus_name, const int port,
void (*port_check)(void)); void (*port_check)(void));
......
...@@ -61,6 +61,15 @@ static void test_init(void) ...@@ -61,6 +61,15 @@ static void test_init(void)
qusb_pci_init_one(pcibus, &ehci1, QPCI_DEVFN(0x1d, 7), 0); 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) static void pci_uhci_port_1(void)
{ {
g_assert(pcibus != NULL); g_assert(pcibus != NULL);
...@@ -161,6 +170,7 @@ int main(int argc, char **argv) ...@@ -161,6 +170,7 @@ int main(int argc, char **argv)
test_init(); test_init();
ret = g_test_run(); ret = g_test_run();
test_deinit();
qtest_end(); qtest_end();
......
...@@ -28,6 +28,7 @@ static void test_port(int port) ...@@ -28,6 +28,7 @@ static void test_port(int port)
g_assert(port > 0); g_assert(port > 0);
qusb_pci_init_one(qs->pcibus, &uhci, QPCI_DEVFN(0x1d, 0), 4); qusb_pci_init_one(qs->pcibus, &uhci, QPCI_DEVFN(0x1d, 0), 4);
uhci_port_test(&uhci, port - 1, UHCI_PORT_CCS); uhci_port_test(&uhci, port - 1, UHCI_PORT_CCS);
uhci_deinit(&uhci);
} }
static void test_port_1(void) static void test_port_1(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册