From nobody Tue Feb 10 09:47:29 2026 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=1610969753; cv=none; d=zohomail.com; s=zohoarc; b=Sk/AEmkc1qo+Vzd1pBlmUYulDsPa46NA8ncVM8P0h+3Gb7Ss3Ob8X+RvDc1u9tzKcfzW2YiKvyeg86g7+pquYgtytmPWze58DC+Np/iGsovBz8MQ4f2Q9zzxeKCaef1G9n/jbBBE5oXr+bROBmm1l21Gef1h8cQ5EERqFkRMY+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610969753; h=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=cMSK870DeKWov4defNWZ7MB0wGgWDJmUL13k2UhEYuo=; b=kRPFWcz2jiLU5PvzaJnslYgbGiUvLrpFacTKkc7UUvoLemKa40Q9V8eYKz/YhwMgYoHRHWQHWMlFXtHmPlaNsUYRX+Ad0Gx5nnbcgPTSYe3X0FCUp6lHSxVjvwc1sVGyBrCJtAWHynp5RlShzl0tE13SiKOwJYC5xkY5U3uCRqw= 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 1610969753365278.2994626028519; Mon, 18 Jan 2021 03:35:53 -0800 (PST) Received: from localhost ([::1]:38460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1Sp6-0002rY-60 for importer@patchew.org; Mon, 18 Jan 2021 06:35:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1Slt-0007y7-Rb; Mon, 18 Jan 2021 06:32:36 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:55349) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1Slm-0000TW-Lg; Mon, 18 Jan 2021 06:32:33 -0500 Received: from localhost.localdomain ([82.252.149.54]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MStOy-1lTQId0hFW-00UMz1; Mon, 18 Jan 2021 12:32:13 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 2/4] pl031: Use timer_free() in the finalize function to avoid memleaks Date: Mon, 18 Jan 2021 12:32:03 +0100 Message-Id: <20210118113205.1915888-3-laurent@vivier.eu> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118113205.1915888-1-laurent@vivier.eu> References: <20210118113205.1915888-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:ZiGxvzKsj0KAfmOmtibw21jlgd3fohYDzstTPc9Hatb1Di5QVvx B2+/MQnGJynWgmrl6brgUyAtYSXa6iQ/N6p9H9gfm0Mwh9QksWZDlDoFDd/xCx/48SBLp6w ZPKFzWUFM1pqy8W7jyBUlsbNPHdA+8fGJRdnyScD2CrUm9LdlTfiAom8hWSCwK/SOnOGoqC 9Qn4Y8V53fYlp1BvGyIWA== X-UI-Out-Filterresults: notjunk:1;V03:K0:061fqQGQQH0=:VdiZ+EudP3JydSwB2Ztj7N CSN0vC9vPlh+CsjU96bbWajpEVwbi6UCw4KNNmKtu1EHbkOpIdYtWD26T3UwVAeVlYEtPPtTJ MmNGILeqhNH7g+HTO2jXjrPGYoFffxqyx/xBYH+s210AMetBrTc2LqTpg4bCbPZR5bWJrrzqX 72+1XBOtVAyO0fUfVOtLcC/gmBRjB8RN4Ly+1c7jCh604J6Ybll2VQfyQJREg50bn2eF8D4q8 ImrVyGZqykwcOH5u90pE7EJtKUkV/uZdWrNiZRIlttbZ9bbJcqhjgeuB3Yswx9mBS83P2RMb6 NsuzoPBhUEDQCAgvcvvXfPhFU9HUAO2ey+B2u1vE+cdIjy5yCGWO4FyQ0co0CoMH2aeITBjRX y/IyZdEp1JaohDVkJ5+7IWPyCnBfd7wr/WwAycCM8ZGJSkPOZ6EHQsCidnImD 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: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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: Peter Maydell , qemu-trivial@nongnu.org, Michael Tokarev , Laurent Vivier , Gan Qixin , Euler Robot Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Gan Qixin When running device-introspect-test, a memory leak occurred in the pl031_in= it function, this patch use timer_free() in the finalize function to fix it. ASAN shows memory leak stack: Direct leak of 48 byte(s) in 1 object(s) allocated from: #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) #2 0xaaabf5621cfc in timer_new_full qemu/include/qemu/timer.h:523 #3 0xaaabf5621cfc in timer_new qemu/include/qemu/timer.h:544 #4 0xaaabf5621cfc in timer_new_ns qemu/include/qemu/timer.h:562 #5 0xaaabf5621cfc in pl031_init qemu/hw/rtc/pl031.c:194 #6 0xaaabf6339f6c in object_initialize_with_type qemu/qom/object.c:515 #7 0xaaabf633a1e0 in object_new_with_type qemu/qom/object.c:729 #8 0xaaabf6375e40 in qmp_device_list_properties qemu/qom/qom-qmp-cmds.c= :153 #9 0xaaabf5a95540 in qdev_device_help qemu/softmmu/qdev-monitor.c:283 #10 0xaaabf5a96940 in qmp_device_add qemu/softmmu/qdev-monitor.c:801 #11 0xaaabf5a96e70 in hmp_device_add qemu/softmmu/qdev-monitor.c:916 #12 0xaaabf5ac0a2c in handle_hmp_command qemu/monitor/hmp.c:1100 Reported-by: Euler Robot Signed-off-by: Gan Qixin Reviewed-by: Peter Maydell Message-Id: <20210112112705.380534-2-ganqixin@huawei.com> Signed-off-by: Laurent Vivier --- hw/rtc/pl031.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/rtc/pl031.c b/hw/rtc/pl031.c index ae47f09635da..2bbb2062ac85 100644 --- a/hw/rtc/pl031.c +++ b/hw/rtc/pl031.c @@ -194,6 +194,13 @@ static void pl031_init(Object *obj) s->timer =3D timer_new_ns(rtc_clock, pl031_interrupt, s); } =20 +static void pl031_finalize(Object *obj) +{ + PL031State *s =3D PL031(obj); + + timer_free(s->timer); +} + static int pl031_pre_save(void *opaque) { PL031State *s =3D opaque; @@ -329,6 +336,7 @@ static const TypeInfo pl031_info =3D { .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(PL031State), .instance_init =3D pl031_init, + .instance_finalize =3D pl031_finalize, .class_init =3D pl031_class_init, }; =20 --=20 2.29.2