From nobody Tue Feb 10 10:03:24 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=1606462070; cv=none; d=zohomail.com; s=zohoarc; b=dqJedjRBPJxCzOKIcBGOKBoYfjzlG/p56fznAi12tjeQa/TIrmPR1YRE9TZfNQpw33rFAug5WCGaziaoP8U4hv9ruz8H+W7G7W8v2kxWjRUZacKSEXcSi1M6WQWSb6N1uh9xuODII8jScqcHQmiuumIWCqm1HvZd6IR9ecDO1OM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606462070; 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=CaSuv5I/61M8cgPDwhjJqKeRvl65P8lS5Taff7h45/Q=; b=dAaYzgORbc839mBsHyRU2LqR7ELVAwaXtEAcRBraXIeACBkL1UnLEHlZ29CcaueolJ2MVFQUwVIkLnqBDVr4Xj9WDgAV7CsN5tH/Wt9gq9ULszA6xNWmamNvhKQVAURu9ragLfxqYtOL50OzlqGsfjjIcU4lcxFvFEobEg9OV3Y= 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 1606462070307895.6426189175827; Thu, 26 Nov 2020 23:27:50 -0800 (PST) Received: from localhost ([::1]:45038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kiYAX-0001xa-4H for importer@patchew.org; Fri, 27 Nov 2020 02:27:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kiY1y-0002U3-6Z; Fri, 27 Nov 2020 02:18:58 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2979) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kiY1u-0007jv-C5; Fri, 27 Nov 2020 02:18:57 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Cj5ZW2SFNzhjDc; Fri, 27 Nov 2020 15:18:27 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Fri, 27 Nov 2020 15:18:39 +0800 From: Gan Qixin To: , Subject: [PATCH 4/7] exynos4210_pwm: Use ptimer_free() in the finalize function to avoid memleaks Date: Fri, 27 Nov 2020 15:18:00 +0800 Message-ID: <20201127071803.2479462-5-ganqixin@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20201127071803.2479462-1-ganqixin@huawei.com> References: <20201127071803.2479462-1-ganqixin@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.191; envelope-from=ganqixin@huawei.com; helo=szxga05-in.huawei.com 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: peter.maydell@linaro.org, zhang.zhanghailiang@huawei.com, Igor Mitsyanko , Gan Qixin , Euler Robot , kuhn.chenqun@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When running device-introspect-test, a memory leak occurred in the exynos42= 10_pwm_init function, so use ptimer_free() in the finalize function to avoid it. ASAN shows memory leak stack: Indirect leak of 240 byte(s) in 5 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 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 #4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562 #5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433 #6 0xaaabf56a36cc in exynos4210_pwm_init /qemu/hw/timer/exynos4210_pwm.= c:401 #7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 #8 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 #9 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.= c:153 #10 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qap= i-commands-qdev.c:59 #11 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 #12 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136 Reported-by: Euler Robot Signed-off-by: Gan Qixin --- Cc: Igor Mitsyanko --- hw/timer/exynos4210_pwm.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c index de181428b4..4764164d5e 100644 --- a/hw/timer/exynos4210_pwm.c +++ b/hw/timer/exynos4210_pwm.c @@ -410,6 +410,16 @@ static void exynos4210_pwm_init(Object *obj) sysbus_init_mmio(dev, &s->iomem); } =20 +static void exynos4210_pwm_finalize(Object *obj) +{ + Exynos4210PWMState *s =3D EXYNOS4210_PWM(obj); + int i; + + for (i =3D 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) { + ptimer_free(s->timer[i].ptimer); + } +} + static void exynos4210_pwm_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -419,11 +429,12 @@ static void exynos4210_pwm_class_init(ObjectClass *kl= ass, void *data) } =20 static const TypeInfo exynos4210_pwm_info =3D { - .name =3D TYPE_EXYNOS4210_PWM, - .parent =3D TYPE_SYS_BUS_DEVICE, - .instance_size =3D sizeof(Exynos4210PWMState), - .instance_init =3D exynos4210_pwm_init, - .class_init =3D exynos4210_pwm_class_init, + .name =3D TYPE_EXYNOS4210_PWM, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(Exynos4210PWMState), + .instance_init =3D exynos4210_pwm_init, + .instance_finalize =3D exynos4210_pwm_finalize, + .class_init =3D exynos4210_pwm_class_init, }; =20 static void exynos4210_pwm_register_types(void) --=20 2.23.0