From: Harsh Prateek Bora <harshpb@linux.ibm.com>
To: BALATON Zoltan <balaton@eik.bme.hu>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
Nicholas Piggin <npiggin@gmail.com>,
Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [PATCH] hw/ppc/pegasos: Fix memory leak
Date: Sun, 9 Nov 2025 18:03:17 +0530 [thread overview]
Message-ID: <63b6e52e-2eb1-4d11-bfda-7048848bcba8@linux.ibm.com> (raw)
In-Reply-To: <5cabe3a8-77a0-b21d-8b73-bbbea049930c@eik.bme.hu>
On 11/3/25 18:03, BALATON Zoltan wrote:
> On Mon, 3 Nov 2025, Harsh Prateek Bora wrote:
>> Hi Balaton,
>>
>> Thanks for taking care of this ...
>>
>> On 11/1/25 22:22, BALATON Zoltan wrote:
>>> Commit 9099b430a4 introduced an early return that caused a leak of a
>>> GString. Allocate it later to avoid the leak.
>>>
>>
>> I think we also want to mention:
>>
>> Reported-by: Peter Maydell <peter.maydell@linaro.org>
>
> You can add it on merge.
>
>>> Fixes: 9099b430a4 (hw/ppc/pegasos2: Change device tree generation)
>>> Resolves: Coverity CID 1642027
>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>> ---
>>> hw/ppc/pegasos.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/ppc/pegasos.c b/hw/ppc/pegasos.c
>>> index 3a498edd16..8ce185de3e 100644
>>> --- a/hw/ppc/pegasos.c
>>> +++ b/hw/ppc/pegasos.c
>>> @@ -847,7 +847,7 @@ static struct {
>>> static void add_pci_device(PCIBus *bus, PCIDevice *d, void *opaque)
>>> {
>>> FDTInfo *fi = opaque;
>>> - GString *node = g_string_new(NULL);
>>> + GString *node;
>>
>> Curious to know if there were any technical reasons for not using
>> g_autoptr which Peter initially suggested ?
>
> Just thought it's simpler and more straight forward this way and saves a
> bit of unnecessary complication. We don't even allocate the string now
> when we exit, with g_autoptr it might do some additional operations
> unnecessarily. As this function otherwise does not have multiple exit
> points just one free at the end works.
Queued, thanks.
prev parent reply other threads:[~2025-11-09 12:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-01 16:52 [PATCH] hw/ppc/pegasos: Fix memory leak BALATON Zoltan
2025-11-02 11:41 ` Peter Maydell
2025-11-03 2:21 ` Harsh Prateek Bora
2025-11-03 9:39 ` Peter Maydell
2025-11-03 9:47 ` Harsh Prateek Bora
2025-11-03 12:33 ` BALATON Zoltan
2025-11-09 12:33 ` Harsh Prateek Bora [this message]
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=63b6e52e-2eb1-4d11-bfda-7048848bcba8@linux.ibm.com \
--to=harshpb@linux.ibm.com \
--cc=balaton@eik.bme.hu \
--cc=npiggin@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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 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).