From patchwork Tue Feb 21 14:14:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 730579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vSNVR6cd5z9s0m for ; Wed, 22 Feb 2017 01:41:35 +1100 (AEDT) Received: from localhost ([::1]:46009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgBdF-0008F3-Cs for incoming@patchwork.ozlabs.org; Tue, 21 Feb 2017 09:41:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgBFW-0002HD-H0 for qemu-devel@nongnu.org; Tue, 21 Feb 2017 09:17:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgBFU-0004hq-Ta for qemu-devel@nongnu.org; Tue, 21 Feb 2017 09:17:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34894) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgBFU-0004hS-Kv for qemu-devel@nongnu.org; Tue, 21 Feb 2017 09:17:00 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2EE9C051665 for ; Tue, 21 Feb 2017 14:17:00 +0000 (UTC) Received: from localhost (ovpn-116-62.phx2.redhat.com [10.3.116.62]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LEGwoN024102; Tue, 21 Feb 2017 09:16:59 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Tue, 21 Feb 2017 18:14:48 +0400 Message-Id: <20170221141451.28305-28-marcandre.lureau@redhat.com> In-Reply-To: <20170221141451.28305-1-marcandre.lureau@redhat.com> References: <20170221141451.28305-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 21 Feb 2017 14:17:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 27/30] tests: fix usb-test leaks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Fix the usb tests leaks. Spotted by ASAN. Cc: Gerd Hoffmann Signed-off-by: Marc-André Lureau Reviewed-by: Gerd Hoffmann --- 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)