From: Stefan Hajnoczi <stefanha@redhat.com>
To: Chandan Somani <csomani@redhat.com>
Cc: qemu-devel@nongnu.org, "Kevin Wolf" <kwolf@redhat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Yoshinori Sato" <yoshinori.sato@nifty.com>,
"Jiri Pirko" <jiri@resnulli.us>,
"Jason Wang" <jasowang@redhat.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
"open list:Stellaris" <qemu-arm@nongnu.org>
Subject: Re: [PATCH] qdev: Free property array on release
Date: Tue, 6 Jan 2026 15:24:18 -0500 [thread overview]
Message-ID: <20260106202418.GD123256@fedora> (raw)
In-Reply-To: <20251222055009.1050567-1-csomani@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2255 bytes --]
On Sun, Dec 21, 2025 at 09:50:05PM -0800, Chandan Somani wrote:
> Before this patch, users of the property array would free the
> array themselves in their cleanup functions. This causes
> inconsistencies where some users leak the array and some free them.
>
> This patch makes it so that the property array's release function
> frees the property array (instead of just its elements). It fixes any
> leaks and requires less code.
>
> Signed-off-by: Chandan Somani <csomani@redhat.com>
> ---
> block/accounting.c | 1 -
> hw/core/qdev-properties.c | 20 ++++++++++----------
> hw/input/stellaris_gamepad.c | 8 --------
> hw/intc/arm_gicv3_common.c | 8 --------
> hw/intc/rx_icu.c | 8 --------
> hw/misc/arm_sysctl.c | 2 --
> hw/misc/mps2-scc.c | 8 --------
> hw/net/rocker/rocker.c | 1 -
> hw/nvram/xlnx-efuse.c | 8 --------
> hw/nvram/xlnx-versal-efuse-ctrl.c | 8 --------
> 10 files changed, 10 insertions(+), 62 deletions(-)
Missing hw/virtio/virtio-iommu-pci.c?
The following DEFINE_PROP_ARRAY() users unintentionally leak their
arrays and are fixed by this patch (I think it's worth mentioning this
in the commit description):
- hw/display/apple-gfx-mmio.m
- hw/display/apple-gfx-pci.m
- hw/net/virtio-net.c
- hw/riscv/riscv_hart.c
> @@ -686,14 +684,16 @@ static void release_prop_array(Object *obj, const char *name, void *opaque)
> char *elem = *arrayptr;
> int i;
>
> - if (!prop->arrayinfo->release) {
> - return;
> + if (prop->arrayinfo->release) {
> + for (i = 0; i < *alenptr; i++) {
> + Property elem_prop = array_elem_prop(obj, prop, name, elem);
> + prop->arrayinfo->release(obj, NULL, &elem_prop);
> + elem += prop->arrayfieldsize;
> + }
> }
>
> - for (i = 0; i < *alenptr; i++) {
> - Property elem_prop = array_elem_prop(obj, prop, name, elem);
> - prop->arrayinfo->release(obj, NULL, &elem_prop);
> - elem += prop->arrayfieldsize;
> + if (*arrayptr) {
> + g_free(*arrayptr);
It is safe to call g_free(NULL), so if (*arrayptr) is unnecessary.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-01-07 16:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-22 5:50 [PATCH] qdev: Free property array on release Chandan Somani
2026-01-06 20:24 ` Stefan Hajnoczi [this message]
2026-01-06 20:30 ` Stefan Hajnoczi
2026-01-07 16:31 ` Daniel P. Berrangé
2026-01-08 8:31 ` Marc-André Lureau
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=20260106202418.GD123256@fedora \
--to=stefanha@redhat.com \
--cc=alistair@alistair23.me \
--cc=berrange@redhat.com \
--cc=csomani@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=eduardo@habkost.net \
--cc=hreitz@redhat.com \
--cc=jasowang@redhat.com \
--cc=jiri@resnulli.us \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=yoshinori.sato@nifty.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.