From: Alistair Francis <alistair23@gmail.com>
To: Pan Nengyuan <pannengyuan@huawei.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
zhang.zhanghailiang@huawei.com,
Alistair Francis <alistair@alistair23.me>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
qemu-arm <qemu-arm@nongnu.org>,
Euler Robot <euler.robot@huawei.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Subject: Re: [PATCH v3 6/6] hw/timer/cadence_ttc: move timer_new from init() into realize() to avoid memleaks
Date: Wed, 26 Feb 2020 22:33:10 -0800 [thread overview]
Message-ID: <CAKmqyKM-nZ6odr6G1dHy6ZMoc+v3e6WoESjPkzmcTYN8totTeg@mail.gmail.com> (raw)
In-Reply-To: <20200227025055.14341-7-pannengyuan@huawei.com>
On Wed, Feb 26, 2020 at 6:37 PM Pan Nengyuan <pannengyuan@huawei.com> wrote:
>
> There are some memleaks when we call 'device_list_properties'. This patch move timer_new from init into realize to fix it.
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Alistair Francis <alistair@alistair23.me>
> ---
> hw/timer/cadence_ttc.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c
> index 5e3128c1e3..b0ba6b2bba 100644
> --- a/hw/timer/cadence_ttc.c
> +++ b/hw/timer/cadence_ttc.c
> @@ -412,16 +412,21 @@ static void cadence_timer_init(uint32_t freq, CadenceTimerState *s)
> static void cadence_ttc_init(Object *obj)
> {
> CadenceTTCState *s = CADENCE_TTC(obj);
> +
> + memory_region_init_io(&s->iomem, obj, &cadence_ttc_ops, s,
> + "timer", 0x1000);
> + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
> +}
> +
> +static void cadence_ttc_realize(DeviceState *dev, Error **errp)
> +{
> + CadenceTTCState *s = CADENCE_TTC(dev);
> int i;
>
> for (i = 0; i < 3; ++i) {
> cadence_timer_init(133000000, &s->timer[i]);
> - sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->timer[i].irq);
> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->timer[i].irq);
> }
> -
> - memory_region_init_io(&s->iomem, obj, &cadence_ttc_ops, s,
> - "timer", 0x1000);
> - sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
> }
>
> static int cadence_timer_pre_save(void *opaque)
> @@ -479,6 +484,7 @@ static void cadence_ttc_class_init(ObjectClass *klass, void *data)
> DeviceClass *dc = DEVICE_CLASS(klass);
>
> dc->vmsd = &vmstate_cadence_ttc;
> + dc->realize = cadence_ttc_realize;
> }
>
> static const TypeInfo cadence_ttc_info = {
> --
> 2.18.2
>
>
next prev parent reply other threads:[~2020-02-27 6:34 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-27 2:50 [PATCH v3 0/6] delay timer_new from init to realize to fix memleaks Pan Nengyuan
2020-02-27 2:50 ` [PATCH v3 1/6] s390x: fix memleaks in cpu_finalize Pan Nengyuan
2020-02-27 8:41 ` David Hildenbrand
2020-02-27 8:55 ` Philippe Mathieu-Daudé
2020-02-27 9:06 ` David Hildenbrand
2020-02-27 8:58 ` Pan Nengyuan
2020-02-27 9:04 ` David Hildenbrand
2020-02-27 9:15 ` Pan Nengyuan
2020-02-27 11:06 ` Cornelia Huck
2020-02-27 11:25 ` Pan Nengyuan
2020-03-02 14:34 ` Stefan Hajnoczi
2020-03-03 1:39 ` Pan Nengyuan
2020-02-27 2:50 ` [PATCH v3 2/6] hw/arm/pxa2xx: move timer_new from init() into realize() to avoid memleaks Pan Nengyuan
2020-02-27 2:50 ` [PATCH v3 3/6] hw/arm/spitz: " Pan Nengyuan
2020-02-27 2:50 ` [PATCH v3 4/6] hw/arm/strongarm: " Pan Nengyuan
2020-02-27 2:50 ` [PATCH v3 5/6] hw/misc/mos6522: " Pan Nengyuan
2020-03-02 13:21 ` Peter Maydell
2020-03-02 19:17 ` Mark Cave-Ayland
2020-03-03 1:36 ` Pan Nengyuan
2020-03-04 20:40 ` Mark Cave-Ayland
2020-02-27 2:50 ` [PATCH v3 6/6] hw/timer/cadence_ttc: " Pan Nengyuan
2020-02-27 6:33 ` Alistair Francis [this message]
2020-03-02 13:21 ` [PATCH v3 0/6] delay timer_new from init to realize to fix memleaks Peter Maydell
2020-03-03 1:26 ` Pan Nengyuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKmqyKM-nZ6odr6G1dHy6ZMoc+v3e6WoESjPkzmcTYN8totTeg@mail.gmail.com \
--to=alistair23@gmail.com \
--cc=alistair@alistair23.me \
--cc=edgar.iglesias@gmail.com \
--cc=euler.robot@huawei.com \
--cc=pannengyuan@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=zhang.zhanghailiang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).