qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Inès Varhol" <ines.varhol@telecom-paris.fr>, qemu-devel@nongnu.org
Cc: Alistair Francis <alistair@alistair23.me>,
	Paolo Bonzini <pbonzini@redhat.com>,
	qemu-arm@nongnu.org,
	Arnaud Minier <arnaud.minier@telecom-paris.fr>,
	Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Samuel Tardieu <samuel.tardieu@telecom-paris.fr>
Subject: Re: [PATCH v2 2/3] hw/arm: Connect STM32L4x5 GPIO to STM32L4x5 SoC
Date: Tue, 23 Jan 2024 09:09:31 +0100	[thread overview]
Message-ID: <d62f9bce-f86b-42db-8c27-6565cf1b8159@linaro.org> (raw)
In-Reply-To: <20240122210829.127691-3-ines.varhol@telecom-paris.fr>

Hi Inès,

On 22/1/24 22:02, Inès Varhol wrote:
> Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
> Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
> ---
>   hw/arm/Kconfig                 |  3 +-
>   hw/arm/stm32l4x5_soc.c         | 79 ++++++++++++++++++++++++++++------
>   include/hw/arm/stm32l4x5_soc.h |  2 +
>   3 files changed, 69 insertions(+), 15 deletions(-)


>   static void stm32l4x5_soc_initfn(Object *obj)
>   {
>       Stm32l4x5SocState *s = STM32L4X5_SOC(obj);
> +    g_autofree char *name = NULL;

        [1]
>   
>       object_initialize_child(obj, "exti", &s->exti, TYPE_STM32L4X5_EXTI);
>       object_initialize_child(obj, "syscfg", &s->syscfg, TYPE_STM32L4X5_SYSCFG);
>       object_initialize_child(obj, "rcc", &s->rcc, TYPE_STM32L4X5_RCC);
> +
> +    for (unsigned i = 0; i < NUM_GPIOS; i++) {
> +        name = g_strdup_printf("gpio%c", 'a' + i);

           [2] // alloc

> +        object_initialize_child(obj, name, &s->gpio[i], TYPE_STM32L4X5_GPIO);

           [3] // expected free

> +    }

       [4] // current autofree

>   }
If you declare the variable to be automatically free'd in the
main body scope [1], it will be free'd when the scope is leaved,
so in [4], meaning only the *last* allocation ("GPIOH") from [2]
will be free'd, all other are leaked. We want to release in [3].

Similar comment applies to stm32l4x5_soc_realize() in this
patch.

See https://docs.gtk.org/glib/auto-cleanup.html for context.

Regards,

Phil.



  reply	other threads:[~2024-01-23  8:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 21:02 [PATCH v2 0/3] Add device STM32L4x5 GPIO Inès Varhol
2024-01-22 21:02 ` [PATCH v2 1/3] hw/gpio: Implement " Inès Varhol
2024-01-22 21:02 ` [PATCH v2 2/3] hw/arm: Connect STM32L4x5 GPIO to STM32L4x5 SoC Inès Varhol
2024-01-23  8:09   ` Philippe Mathieu-Daudé [this message]
2024-01-22 21:02 ` [PATCH v2 3/3] tests/qtest: Add STM32L4x5 GPIO QTest testcase Inès Varhol

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=d62f9bce-f86b-42db-8c27-6565cf1b8159@linaro.org \
    --to=philmd@linaro.org \
    --cc=alistair@alistair23.me \
    --cc=arnaud.minier@telecom-paris.fr \
    --cc=ines.varhol@telecom-paris.fr \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.tardieu@telecom-paris.fr \
    --cc=thuth@redhat.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).