qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: pannengyuan@huawei.com, peter.maydell@linaro.org
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	zhang.zhanghailiang@huawei.com,
	Euler Robot <euler.robot@huawei.com>
Subject: Re: [PATCH 3/3] stellaris: delay timer_new to avoid memleaks
Date: Wed, 5 Feb 2020 14:10:16 +0100	[thread overview]
Message-ID: <71c5dc35-d2f2-6a7e-dde3-408fc24bb425@redhat.com> (raw)
In-Reply-To: <20200205070659.22488-4-pannengyuan@huawei.com>

On 2/5/20 8:06 AM, pannengyuan@huawei.com wrote:
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> There is a memory leak when we call 'device_list_properties' with typename = stellaris-gptm. It's easy to reproduce as follow:
> 
>    virsh qemu-monitor-command vm1 --pretty '{"execute": "device-list-properties", "arguments": {"typename": "stellaris-gptm"}}'
> 
> This patch delay timer_new in realize to fix it.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Cc: qemu-arm@nongnu.org
> ---
>   hw/arm/stellaris.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
> index bb025e0bd0..221a78674e 100644
> --- a/hw/arm/stellaris.c
> +++ b/hw/arm/stellaris.c
> @@ -347,11 +347,15 @@ static void stellaris_gptm_init(Object *obj)
>       sysbus_init_mmio(sbd, &s->iomem);
>   
>       s->opaque[0] = s->opaque[1] = s;
> +}
> +
> +static void stellaris_gptm_realize(DeviceState *dev, Error **errp)
> +{
> +    gptm_state *s = STELLARIS_GPTM(dev);
>       s->timer[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[0]);
>       s->timer[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[1]);
>   }
>   
> -
>   /* System controller.  */
>   
>   typedef struct {
> @@ -1536,6 +1540,7 @@ static void stellaris_gptm_class_init(ObjectClass *klass, void *data)
>       DeviceClass *dc = DEVICE_CLASS(klass);
>   
>       dc->vmsd = &vmstate_stellaris_gptm;
> +    dc->realize = stellaris_gptm_realize;
>   }
>   
>   static const TypeInfo stellaris_gptm_info = {
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



  reply	other threads:[~2020-02-05 13:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05  7:06 [PATCH 0/3] delay timer_new to avoid memleaks pannengyuan
2020-02-05  7:06 ` [PATCH 1/3] armv7m_systick: " pannengyuan
2020-02-05  7:06 ` [PATCH 2/3] stm32f2xx_timer: " pannengyuan
2020-02-05 13:17   ` Philippe Mathieu-Daudé
2020-02-05 18:49   ` Alistair Francis
2020-02-05  7:06 ` [PATCH 3/3] stellaris: " pannengyuan
2020-02-05 13:10   ` Philippe Mathieu-Daudé [this message]
2020-02-05 13:16 ` [PATCH 0/3] " Philippe Mathieu-Daudé
2020-02-06  1:14   ` Pan Nengyuan
2020-02-07 13:42 ` Peter Maydell

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=71c5dc35-d2f2-6a7e-dde3-408fc24bb425@redhat.com \
    --to=philmd@redhat.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).