From nobody Mon Apr 7 18:09:27 2025 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581087818030739.8855454854372; Fri, 7 Feb 2020 07:03:38 -0800 (PST) Received: from localhost ([::1]:58816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j05AO-0003Vd-PX for importer@patchew.org; Fri, 07 Feb 2020 10:03:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52005) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j04iM-0001bz-DB for qemu-devel@nongnu.org; Fri, 07 Feb 2020 09:34:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j04iL-0003hd-AQ for qemu-devel@nongnu.org; Fri, 07 Feb 2020 09:34:38 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:36288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j04iL-0003g9-4A for qemu-devel@nongnu.org; Fri, 07 Feb 2020 09:34:37 -0500 Received: by mail-wr1-x435.google.com with SMTP id z3so2977071wru.3 for ; Fri, 07 Feb 2020 06:34:37 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id w1sm3796430wro.72.2020.02.07.06.34.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2020 06:34:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UCTgH8+JIicTcdeMwWbA7Fm/8BcoGqpf7BduEhNp0D4=; b=CCzqjVQc8rRlDBbpCApRo2A5ieyiXwCmKzZ/BGTnZDIyvtwTtGek6Zh5eLbmayo2s/ iM4PnzSQTkZDzxagoMlKmjRUnvXzOGCfjKzhAMmwlWZWAlqLUKq40CXu0dCbQTCsACqX /ljvKwuOGueL9q9zlNZuWuvQVIXtoGMvp5oVMKYAoB2fSpoh5Dt1HbWtqvamAn2jnGDh 5L96lSydfQsJXVLBR40T3FwEnI7qAUE+OnlaDr/DUWwy6x6QCt8f6WV1vtcGLNNL8oas N98hrkzplVMqK9bAhuJ4o7DC/8ntAxOFKKNkVtQBLHB3D9NSSJXKNffRky5sJNIcmIMb OT0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UCTgH8+JIicTcdeMwWbA7Fm/8BcoGqpf7BduEhNp0D4=; b=cu71lDJqgkcb0Qf8B/0MZLFfMiVqjrzUHo1fQevROyM+oaNMAFh63BTqnaFJLnnFLg 9ppNX90fLecClSiexXwS1c00VxaIgobJpP15tS366rCA2tIgjsYZ7eZ81c43wwc+0dct 2rwdsGRphBUHKkLkzNEVGZsrZP3oj1FIkSZv8PZ29KZfijLybFJh+D1+54/b4GmPZhyi rkzw6PjRCqs0lY7PTHQgFT++L9FB2bnE8GE/BDE8Tz/YLCTLIInaCUfF3TnadS9Q+v0Q NAZ1T9drtFZv+Upq7bqvmmyuzgFesrZmuOo/YIJivhuU+Gg3US4h44Yy7+dL+FGlrpcs 9CUQ== X-Gm-Message-State: APjAAAVo6eO2fGvu3aGWZWh7Dg636KZ7qtM301w9s2JS0+5vm7qHRQK+ w/AQKaEo2iLkdxl5ZpZvoOFBkVyN96I= X-Google-Smtp-Source: APXvYqyLN30NEzqyXqmVE9laItkjptCrsW0Xa5YAU5yPfxJOnn9WQsuyiOPoqDYWXtshcBft7puaEw== X-Received: by 2002:adf:ab14:: with SMTP id q20mr4965372wrc.274.1581086075868; Fri, 07 Feb 2020 06:34:35 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 47/48] stm32f2xx_timer: delay timer_new to avoid memleaks Date: Fri, 7 Feb 2020 14:33:42 +0000 Message-Id: <20200207143343.30322-48-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200207143343.30322-1-peter.maydell@linaro.org> References: <20200207143343.30322-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Pan Nengyuan There is a memory leak when we call 'device_list_properties' with typename = =3D stm32f2xx_timer. It's easy to reproduce as follow: virsh qemu-monitor-command vm1 --pretty '{"execute": "device-list-prope= rties", "arguments": {"typename": "stm32f2xx_timer"}}' This patch delay timer_new to fix this memleaks. Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-id: 20200205070659.22488-3-pannengyuan@huawei.com Cc: Alistair Francis Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/timer/stm32f2xx_timer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/timer/stm32f2xx_timer.c b/hw/timer/stm32f2xx_timer.c index fb370ce0f05..06ec8a02c25 100644 --- a/hw/timer/stm32f2xx_timer.c +++ b/hw/timer/stm32f2xx_timer.c @@ -314,7 +314,11 @@ static void stm32f2xx_timer_init(Object *obj) memory_region_init_io(&s->iomem, obj, &stm32f2xx_timer_ops, s, "stm32f2xx_timer", 0x400); sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); +} =20 +static void stm32f2xx_timer_realize(DeviceState *dev, Error **errp) +{ + STM32F2XXTimerState *s =3D STM32F2XXTIMER(dev); s->timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, stm32f2xx_timer_interrup= t, s); } =20 @@ -325,6 +329,7 @@ static void stm32f2xx_timer_class_init(ObjectClass *kla= ss, void *data) dc->reset =3D stm32f2xx_timer_reset; device_class_set_props(dc, stm32f2xx_timer_properties); dc->vmsd =3D &vmstate_stm32f2xx_timer; + dc->realize =3D stm32f2xx_timer_realize; } =20 static const TypeInfo stm32f2xx_timer_info =3D { --=20 2.20.1