From nobody Sun May 5 23:58:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1605700752; cv=none; d=zohomail.com; s=zohoarc; b=Rx0AMmsUAIGXD8dpp14UL0WwV2qQK4bBOs9wO2oMMg37SbfsTI7sHQRM4SveHUZRFleTFeajpr+pzfONxQecXOr/qdMSe2VgXVJFFBnz+D06A7z44gdH0tN+FIckMonRzei5WlISorDHYyHg6KdmtZk6lj01Gs/k0uQQXXEMWQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605700752; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DDJ3gdAR7Cv0peeFYjY/xPrF3sHUNtRlmFVtyLoJ6Ew=; b=Br/iNGO5+mIUXpDPGvLsUG/UCo8UGAU138DL1jll5+qLEdVG0mQ32N3zHhhQY4oNCKii0PjgedoJd5szrZZA4Q2TotYB+a5neBuJ0j2Y6VpripCZPLBQI6srAE+ZhPPn+4zd//AxLaoI0FBvYAPgGJCRySWN8bwlWLfB5lpU8sM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605700752887245.68195970256124; Wed, 18 Nov 2020 03:59:12 -0800 (PST) Received: from localhost ([::1]:39594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfM7D-0002Qu-QX for importer@patchew.org; Wed, 18 Nov 2020 06:59:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfM5i-00010j-Ut; Wed, 18 Nov 2020 06:57:38 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2458) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfM5g-00084M-Kj; Wed, 18 Nov 2020 06:57:38 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CbhB543qWzLq53; Wed, 18 Nov 2020 19:57:01 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Wed, 18 Nov 2020 19:57:12 +0800 From: Chen Qun To: , Subject: [PATCH-for-5.2? 1/2] tests/qtest: variable defined by g_autofree need to be initialized Date: Wed, 18 Nov 2020 19:56:45 +0800 Message-ID: <20201118115646.2461726-2-kuhn.chenqun@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201118115646.2461726-1-kuhn.chenqun@huawei.com> References: <20201118115646.2461726-1-kuhn.chenqun@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.191; envelope-from=kuhn.chenqun@huawei.com; helo=szxga05-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/18 06:57:21 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, peter.maydell@linaro.org, thuth@redhat.com, zhang.zhanghailiang@huawei.com, hskinnemoen@google.com, wuhaotsh@google.com, Euler Robot , Chen Qun Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" According to the glib function requirements, we need initialise the variable. Otherwise there will be compilation warnings: glib-autocleanups.h:28:3: warning: =E2=80=98full_name=E2=80=99 may be used uninitialized in this function [-Wmaybe-uninitialized] 28 | g_free (*pp); | ^~~~~~~~~~~~ Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Havard Skinnemoen Reviewed-by: Thomas Huth --- tests/qtest/npcm7xx_timer-test.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/qtest/npcm7xx_timer-test.c b/tests/qtest/npcm7xx_timer-t= est.c index f08b0cd62a..83774a5b90 100644 --- a/tests/qtest/npcm7xx_timer-test.c +++ b/tests/qtest/npcm7xx_timer-test.c @@ -512,11 +512,9 @@ static void test_disable_on_expiration(gconstpointer t= est_data) */ static void tim_add_test(const char *name, const TestData *td, GTestDataFu= nc fn) { - g_autofree char *full_name; - - full_name =3D g_strdup_printf("npcm7xx_timer/tim[%d]/timer[%d]/%s", - tim_index(td->tim), timer_index(td->timer), - name); + g_autofree char *full_name =3D g_strdup_printf( + "npcm7xx_timer/tim[%d]/timer[%d]/%s", tim_index(td->tim), + timer_index(td->timer), name); qtest_add_data_func(full_name, td, fn); } =20 --=20 2.23.0 From nobody Sun May 5 23:58:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1605700764; cv=none; d=zohomail.com; s=zohoarc; b=AnOQ+J1UF4Ut7vVfpd69O2+hyL+cQ8d+mU/QKkvxb6cx5wTb1FZSUKf/DLy/d5L5BMyVD3Xh716BNRl/t8fW9x2TjicYeZetWrjWya/JLpcCxHVKjkyYrYBYVXXIBXV5iL7t/yNFR9fEvwpCZMPojOEC/6nH7WtYqY8F036G2mU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605700764; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jbIxNhKLsuhpWgSFyaacoP9NXUfFC3k5hOJLlbdOoqA=; b=aNwJEzhFA2jRMlsuB8hSnCtj5Ivthcf0qD6JFWrhanI130LWqh66jMFhbAS1PvBzjL4upCfKUse+mjvw0ndK9gLC0Ozy/pJjFkp+WBjKhPZe612Pia9y2uOPv3ehhOHqpUd1ebw9K9vaaSBlgGWrW4IC9E1frOTEzm+3znlUQYY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605700764560586.7182070179425; Wed, 18 Nov 2020 03:59:24 -0800 (PST) Received: from localhost ([::1]:40416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfM7P-0002lv-5o for importer@patchew.org; Wed, 18 Nov 2020 06:59:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfM5n-00019Z-Sr; Wed, 18 Nov 2020 06:57:43 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2796) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfM5l-00084Z-EI; Wed, 18 Nov 2020 06:57:43 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CbhBB6v2TzkZhZ; Wed, 18 Nov 2020 19:57:06 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Wed, 18 Nov 2020 19:57:15 +0800 From: Chen Qun To: , Subject: [PATCH-for-5.2? 2/2] tests/qtest: fix memleak in npcm7xx_watchdog_timer-test Date: Wed, 18 Nov 2020 19:56:46 +0800 Message-ID: <20201118115646.2461726-3-kuhn.chenqun@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201118115646.2461726-1-kuhn.chenqun@huawei.com> References: <20201118115646.2461726-1-kuhn.chenqun@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.190; envelope-from=kuhn.chenqun@huawei.com; helo=szxga04-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/18 06:57:26 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, peter.maydell@linaro.org, thuth@redhat.com, zhang.zhanghailiang@huawei.com, hskinnemoen@google.com, wuhaotsh@google.com, Euler Robot , Chen Qun Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Properly free resp for get_watchdog_action() to avoid memory leak. ASAN shows memory leak stack: Indirect leak of 12360 byte(s) in 3 object(s) allocated from: #0 0x7f41ab6cbd4e in __interceptor_calloc (/lib64/libasan.so.5+0x112d4e) #1 0x7f41ab4eaa50 in g_malloc0 (/lib64/libglib-2.0.so.0+0x55a50) #2 0x556487d5374b in qdict_new ../qobject/qdict.c:29 #3 0x556487d65e1a in parse_object ../qobject/json-parser.c:318 #4 0x556487d65cb6 in parse_pair ../qobject/json-parser.c:287 #5 0x556487d65ebd in parse_object ../qobject/json-parser.c:343 #6 0x556487d661d5 in json_parser_parse ../qobject/json-parser.c:580 #7 0x556487d513df in json_message_process_token ../qobject/json-streame= r.c:92 #8 0x556487d63919 in json_lexer_feed_char ../qobject/json-lexer.c:313 #9 0x556487d63d75 in json_lexer_feed ../qobject/json-lexer.c:350 #10 0x556487d28b2a in qmp_fd_receive ../tests/qtest/libqtest.c:613 #11 0x556487d2a16f in qtest_qmp_eventwait_ref ../tests/qtest/libqtest.c= :827 #12 0x556487d248e2 in get_watchdog_action ../tests/qtest/npcm7xx_watchd= og_timer-test.c:94 #13 0x556487d25765 in test_enabling_flags ../tests/qtest/npcm7xx_watchd= og_timer-test.c:243 Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Havard Skinnemoen --- tests/qtest/npcm7xx_watchdog_timer-test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/qtest/npcm7xx_watchdog_timer-test.c b/tests/qtest/npcm7x= x_watchdog_timer-test.c index 54d5d6d8f2..3aae5a0438 100644 --- a/tests/qtest/npcm7xx_watchdog_timer-test.c +++ b/tests/qtest/npcm7xx_watchdog_timer-test.c @@ -204,6 +204,7 @@ static void test_enabling_flags(gconstpointer watchdog) { const Watchdog *wd =3D watchdog; QTestState *qts; + QDict *rsp; =20 /* Neither WTIE or WTRE is set, no interrupt or reset should happen */ qts =3D qtest_init("-machine quanta-gsj"); @@ -240,8 +241,9 @@ static void test_enabling_flags(gconstpointer watchdog) g_assert_false(qtest_get_irq(qts, wd->irq)); qtest_clock_step(qts, watchdog_calculate_steps(RESET_CYCLES, watchdog_prescaler(qts, wd))); - g_assert_false(strcmp(qdict_get_str(get_watchdog_action(qts), "action"= ), - "reset")); + rsp =3D get_watchdog_action(qts); + g_assert_false(strcmp(qdict_get_str(rsp, "action"), "reset")); + qobject_unref(rsp); qtest_qmp_eventwait(qts, "RESET"); qtest_quit(qts); =20 --=20 2.23.0