[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 6/6] hw/timer/cadence_ttc: move timer_new from init() into
From: |
Alistair Francis |
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 |
On Wed, Feb 26, 2020 at 6:37 PM Pan Nengyuan <address@hidden> 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 <address@hidden>
> Signed-off-by: Pan Nengyuan <address@hidden>
Reviewed-by: Alistair Francis <address@hidden>
Alistair
> ---
> Cc: "Edgar E. Iglesias" <address@hidden>
> Cc: Alistair Francis <address@hidden>
> ---
> 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
>
>
- [PATCH v3 0/6] delay timer_new from init to realize to fix memleaks., Pan Nengyuan, 2020/02/26
- [PATCH v3 4/6] hw/arm/strongarm: move timer_new from init() into realize() to avoid memleaks, Pan Nengyuan, 2020/02/26
- [PATCH v3 3/6] hw/arm/spitz: move timer_new from init() into realize() to avoid memleaks, Pan Nengyuan, 2020/02/26
- [PATCH v3 2/6] hw/arm/pxa2xx: move timer_new from init() into realize() to avoid memleaks, Pan Nengyuan, 2020/02/26
- [PATCH v3 6/6] hw/timer/cadence_ttc: move timer_new from init() into realize() to avoid memleaks, Pan Nengyuan, 2020/02/26
- Re: [PATCH v3 6/6] hw/timer/cadence_ttc: move timer_new from init() into realize() to avoid memleaks,
Alistair Francis <=
- [PATCH v3 5/6] hw/misc/mos6522: move timer_new from init() into realize() to avoid memleaks, Pan Nengyuan, 2020/02/26
- [PATCH v3 1/6] s390x: fix memleaks in cpu_finalize, Pan Nengyuan, 2020/02/26
Re: [PATCH v3 1/6] s390x: fix memleaks in cpu_finalize, Cornelia Huck, 2020/02/27