From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Li Zhijian <lizhijian@fujitsu.com>
Cc: qemu-devel@nongnu.org, imammedo@redhat.com, mst@redhat.com,
anisinha@redhat.com
Subject: Re: [PATCH v2] hw/acpi: Fix GPtrArray memory leak in crs_range_merge
Date: Fri, 13 Jun 2025 10:05:08 +0100 [thread overview]
Message-ID: <aEvpxGwmxXrUBVRn@redhat.com> (raw)
In-Reply-To: <20250613085110.111204-1-lizhijian@fujitsu.com>
On Fri, Jun 13, 2025 at 04:51:10PM +0800, Li Zhijian wrote:
> This leak was detected by the valgrind.
>
> The crs_range_merge() function unconditionally allocated a GPtrArray
> 'even when range->len was zero, causing an early return without freeing
> the allocated array. This resulted in a memory leak when an empty range
> was processed.
>
> Instead of moving the allocation after the check (as previously attempted),
> use g_autoptr for automatic cleanup. This ensures the array is freed even
> on early returns, and also removes the need for the explicit free at the
> end of the function.
>
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2025-06-13 9:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 8:51 [PATCH v2] hw/acpi: Fix GPtrArray memory leak in crs_range_merge Li Zhijian via
2025-06-13 9:05 ` Daniel P. Berrangé [this message]
2025-06-13 10:16 ` Ani Sinha
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=aEvpxGwmxXrUBVRn@redhat.com \
--to=berrange@redhat.com \
--cc=anisinha@redhat.com \
--cc=imammedo@redhat.com \
--cc=lizhijian@fujitsu.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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.