From nobody Mon Feb 9 13:26:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488359582601915.6125292997749; Wed, 1 Mar 2017 01:13:02 -0800 (PST) Received: from localhost ([::1]:39190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cj0Jf-0000Yh-H0 for importer@patchew.org; Wed, 01 Mar 2017 04:12:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cj0D0-0003Mz-5i for qemu-devel@nongnu.org; Wed, 01 Mar 2017 04:06:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cj0Cw-0001fU-15 for qemu-devel@nongnu.org; Wed, 01 Mar 2017 04:06:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cj0Cv-0001f6-8k for qemu-devel@nongnu.org; Wed, 01 Mar 2017 04:06:01 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E32B4E024 for ; Wed, 1 Mar 2017 09:06:01 +0000 (UTC) Received: from localhost (ovpn-116-175.phx2.redhat.com [10.3.116.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77F592D655; Wed, 1 Mar 2017 09:06:00 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 1 Mar 2017 13:04:42 +0400 Message-Id: <20170301090453.11075-18-marcandre.lureau@redhat.com> In-Reply-To: <20170301090453.11075-1-marcandre.lureau@redhat.com> References: <20170301090453.11075-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 01 Mar 2017 09:06:01 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PULL 17/28] tests: fix tco-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?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Spotted by ASAN. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- tests/tco-test.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/tco-test.c b/tests/tco-test.c index ef02ec5903..c4c264eb3d 100644 --- a/tests/tco-test.c +++ b/tests/tco-test.c @@ -42,11 +42,18 @@ typedef struct { bool noreboot; QPCIDevice *dev; QPCIBar tco_io_bar; + QPCIBus *bus; } TestData; =20 +static void test_end(TestData *d) +{ + g_free(d->dev); + qpci_free_pc(d->bus); + qtest_end(); +} + static void test_init(TestData *d) { - QPCIBus *bus; QTestState *qs; char *s; =20 @@ -57,8 +64,8 @@ static void test_init(TestData *d) qtest_irq_intercept_in(qs, "ioapic"); g_free(s); =20 - bus =3D qpci_init_pc(NULL); - d->dev =3D qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00)); + d->bus =3D qpci_init_pc(NULL); + d->dev =3D qpci_device_find(d->bus, QPCI_DEVFN(0x1f, 0x00)); g_assert(d->dev !=3D NULL); =20 qpci_device_enable(d->dev); @@ -148,7 +155,7 @@ static void test_tco_defaults(void) SW_IRQ_GEN_DEFAULT); g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_bar, TCO_TMR), =3D=3D, TCO_TMR_DEFAULT); - qtest_end(); + test_end(&d); } =20 static void test_tco_timeout(void) @@ -192,7 +199,7 @@ static void test_tco_timeout(void) g_assert(ret =3D=3D 1); =20 stop_tco(&d); - qtest_end(); + test_end(&d); } =20 static void test_tco_max_timeout(void) @@ -225,7 +232,7 @@ static void test_tco_max_timeout(void) g_assert(ret =3D=3D 1); =20 stop_tco(&d); - qtest_end(); + test_end(&d); } =20 static QDict *get_watchdog_action(void) @@ -262,7 +269,7 @@ static void test_tco_second_timeout_pause(void) QDECREF(ad); =20 stop_tco(&td); - qtest_end(); + test_end(&td); } =20 static void test_tco_second_timeout_reset(void) @@ -287,7 +294,7 @@ static void test_tco_second_timeout_reset(void) QDECREF(ad); =20 stop_tco(&td); - qtest_end(); + test_end(&td); } =20 static void test_tco_second_timeout_shutdown(void) @@ -312,7 +319,7 @@ static void test_tco_second_timeout_shutdown(void) QDECREF(ad); =20 stop_tco(&td); - qtest_end(); + test_end(&td); } =20 static void test_tco_second_timeout_none(void) @@ -337,7 +344,7 @@ static void test_tco_second_timeout_none(void) QDECREF(ad); =20 stop_tco(&td); - qtest_end(); + test_end(&td); } =20 static void test_tco_ticks_counter(void) @@ -365,7 +372,7 @@ static void test_tco_ticks_counter(void) } while (!(qpci_io_readw(d.dev, d.tco_io_bar, TCO1_STS) & TCO_TIMEOUT)= ); =20 stop_tco(&d); - qtest_end(); + test_end(&d); } =20 static void test_tco1_control_bits(void) @@ -383,7 +390,7 @@ static void test_tco1_control_bits(void) qpci_io_writew(d.dev, d.tco_io_bar, TCO1_CNT, val); g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_bar, TCO1_CNT), =3D=3D, TCO_LOCK); - qtest_end(); + test_end(&d); } =20 static void test_tco1_status_bits(void) @@ -412,7 +419,7 @@ static void test_tco1_status_bits(void) g_assert(ret =3D=3D 1); qpci_io_writew(d.dev, d.tco_io_bar, TCO1_STS, val); g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_bar, TCO1_STS), =3D=3D, = 0); - qtest_end(); + test_end(&d); } =20 static void test_tco2_status_bits(void) @@ -439,7 +446,7 @@ static void test_tco2_status_bits(void) g_assert(ret =3D=3D 1); qpci_io_writew(d.dev, d.tco_io_bar, TCO2_STS, val); g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_bar, TCO2_STS), =3D=3D, = 0); - qtest_end(); + test_end(&d); } =20 int main(int argc, char **argv) --=20 2.12.0.rc2.3.gc93709801