* [PATCH 1/2] hw/ppc: Fix missing return on allocation failure
@ 2025-10-28 6:58 Shivang Upadhyay
2025-10-28 6:58 ` [PATCH 2/2] hw/ppc: Fix memory leak in get_cpu_state_data() Shivang Upadhyay
0 siblings, 1 reply; 5+ messages in thread
From: Shivang Upadhyay @ 2025-10-28 6:58 UTC (permalink / raw)
To: peter.maydell; +Cc: adityag, harshpb, qemu-devel, shivangu, sourabhjain
Fixes coverity (CID 1642026)
Cc: Aditya Gupta <adityag@linux.ibm.com>
Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/CAFEAcA-SPmsnU1wzsWxBcFC=ZM_DDhPEg1N4iX9Q4bL1xOnwBg@mail.gmail.com/
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Shivang Upadhyay <shivangu@linux.ibm.com>
---
hw/ppc/spapr_fadump.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/ppc/spapr_fadump.c b/hw/ppc/spapr_fadump.c
index fa3aeac94c..883a60cdcf 100644
--- a/hw/ppc/spapr_fadump.c
+++ b/hw/ppc/spapr_fadump.c
@@ -234,6 +234,7 @@ static bool do_preserve_region(FadumpSection *region)
qemu_log_mask(LOG_GUEST_ERROR,
"FADump: Failed allocating memory (size: %zu) for copying"
" reserved memory regions\n", FADUMP_CHUNK_SIZE);
+ return false;
}
num_chunks = ceil((src_len * 1.0f) / FADUMP_CHUNK_SIZE);
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] hw/ppc: Fix memory leak in get_cpu_state_data()
2025-10-28 6:58 [PATCH 1/2] hw/ppc: Fix missing return on allocation failure Shivang Upadhyay
@ 2025-10-28 6:58 ` Shivang Upadhyay
2025-10-28 7:12 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 5+ messages in thread
From: Shivang Upadhyay @ 2025-10-28 6:58 UTC (permalink / raw)
To: peter.maydell; +Cc: adityag, harshpb, qemu-devel, shivangu, sourabhjain
Fixes coverity (CID 1642024)
Cc: Aditya Gupta <adityag@linux.ibm.com>
Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
Link: https://lore.kernel.org/qemu-devel/CAFEAcA_Bm52bkPi9MH_uugXRR5fj48RtpbOnPNFQtbX=7Mz_yw@mail.gmail.com/
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Shivang Upadhyay <shivangu@linux.ibm.com>
---
hw/ppc/spapr_fadump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/ppc/spapr_fadump.c b/hw/ppc/spapr_fadump.c
index 883a60cdcf..49d2f862a1 100644
--- a/hw/ppc/spapr_fadump.c
+++ b/hw/ppc/spapr_fadump.c
@@ -453,7 +453,7 @@ static FadumpRegEntry *populate_cpu_reg_entries(CPUState *cpu,
static void *get_cpu_state_data(uint64_t *cpu_state_len)
{
FadumpRegSaveAreaHeader reg_save_hdr;
- FadumpRegEntry *reg_entries;
+ g_autofree FadumpRegEntry *reg_entries;
FadumpRegEntry *curr_reg_entry;
CPUState *cpu;
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] hw/ppc: Fix memory leak in get_cpu_state_data()
2025-10-28 6:58 ` [PATCH 2/2] hw/ppc: Fix memory leak in get_cpu_state_data() Shivang Upadhyay
@ 2025-10-28 7:12 ` Philippe Mathieu-Daudé
2025-10-28 7:30 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 7:12 UTC (permalink / raw)
To: Shivang Upadhyay, peter.maydell; +Cc: adityag, harshpb, qemu-devel, sourabhjain
Hi Shivang,
On 28/10/25 07:58, Shivang Upadhyay wrote:
> Fixes coverity (CID 1642024)
>
> Cc: Aditya Gupta <adityag@linux.ibm.com>
> Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
> Link: https://lore.kernel.org/qemu-devel/CAFEAcA_Bm52bkPi9MH_uugXRR5fj48RtpbOnPNFQtbX=7Mz_yw@mail.gmail.com/
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Shivang Upadhyay <shivangu@linux.ibm.com>
> ---
> hw/ppc/spapr_fadump.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/ppc/spapr_fadump.c b/hw/ppc/spapr_fadump.c
> index 883a60cdcf..49d2f862a1 100644
> --- a/hw/ppc/spapr_fadump.c
> +++ b/hw/ppc/spapr_fadump.c
> @@ -453,7 +453,7 @@ static FadumpRegEntry *populate_cpu_reg_entries(CPUState *cpu,
> static void *get_cpu_state_data(uint64_t *cpu_state_len)
> {
> FadumpRegSaveAreaHeader reg_save_hdr;
> - FadumpRegEntry *reg_entries;
> + g_autofree FadumpRegEntry *reg_entries;
g_autofree pointers have to be NULL-initialized. I don't remember why,
likely CPP warnings.
> FadumpRegEntry *curr_reg_entry;
> CPUState *cpu;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] hw/ppc: Fix memory leak in get_cpu_state_data()
2025-10-28 7:12 ` Philippe Mathieu-Daudé
@ 2025-10-28 7:30 ` Philippe Mathieu-Daudé
2025-10-28 7:36 ` Shivang Upadhyay
0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-28 7:30 UTC (permalink / raw)
To: Shivang Upadhyay, peter.maydell; +Cc: adityag, harshpb, qemu-devel, sourabhjain
On 28/10/25 08:12, Philippe Mathieu-Daudé wrote:
> Hi Shivang,
>
> On 28/10/25 07:58, Shivang Upadhyay wrote:
>> Fixes coverity (CID 1642024)
>>
>> Cc: Aditya Gupta <adityag@linux.ibm.com>
>> Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
>> Link: https://lore.kernel.org/qemu-devel/
>> CAFEAcA_Bm52bkPi9MH_uugXRR5fj48RtpbOnPNFQtbX=7Mz_yw@mail.gmail.com/
>> Reported-by: Peter Maydell <peter.maydell@linaro.org>
>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Shivang Upadhyay <shivangu@linux.ibm.com>
>> ---
>> hw/ppc/spapr_fadump.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/ppc/spapr_fadump.c b/hw/ppc/spapr_fadump.c
>> index 883a60cdcf..49d2f862a1 100644
>> --- a/hw/ppc/spapr_fadump.c
>> +++ b/hw/ppc/spapr_fadump.c
>> @@ -453,7 +453,7 @@ static FadumpRegEntry
>> *populate_cpu_reg_entries(CPUState *cpu,
>> static void *get_cpu_state_data(uint64_t *cpu_state_len)
>> {
>> FadumpRegSaveAreaHeader reg_save_hdr;
>> - FadumpRegEntry *reg_entries;
>> + g_autofree FadumpRegEntry *reg_entries;
>
> g_autofree pointers have to be NULL-initialized. I don't remember why,
> likely CPP warnings.
Ah, see for example commit c8f48b120b3:
As mentioned in docs/devel/style.rst "Automatic memory deallocation":
* Variables declared with g_auto* MUST always be initialized,
otherwise the cleanup function will use uninitialized stack memory
and for full context, commit 821f2967562 ("docs: document use of
automatic cleanup functions in glib").
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] hw/ppc: Fix memory leak in get_cpu_state_data()
2025-10-28 7:30 ` Philippe Mathieu-Daudé
@ 2025-10-28 7:36 ` Shivang Upadhyay
0 siblings, 0 replies; 5+ messages in thread
From: Shivang Upadhyay @ 2025-10-28 7:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: peter.maydell, adityag, harshpb, qemu-devel, sourabhjain,
shivangu
On Tue, Oct 28, 2025 at 08:30:05AM +0100, Philippe Mathieu-Daudé wrote:
> On 28/10/25 08:12, Philippe Mathieu-Daudé wrote:
> > Hi Shivang,
> >
> > On 28/10/25 07:58, Shivang Upadhyay wrote:
> > > Fixes coverity (CID 1642024)
> > >
> > > Cc: Aditya Gupta <adityag@linux.ibm.com>
> > > Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
> > > Link: https://lore.kernel.org/qemu-devel/
> > > CAFEAcA_Bm52bkPi9MH_uugXRR5fj48RtpbOnPNFQtbX=7Mz_yw@mail.gmail.com/
> > > Reported-by: Peter Maydell <peter.maydell@linaro.org>
> > > Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> > > Signed-off-by: Shivang Upadhyay <shivangu@linux.ibm.com>
> > > ---
> > > hw/ppc/spapr_fadump.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/hw/ppc/spapr_fadump.c b/hw/ppc/spapr_fadump.c
> > > index 883a60cdcf..49d2f862a1 100644
> > > --- a/hw/ppc/spapr_fadump.c
> > > +++ b/hw/ppc/spapr_fadump.c
> > > @@ -453,7 +453,7 @@ static FadumpRegEntry
> > > *populate_cpu_reg_entries(CPUState *cpu,
> > > static void *get_cpu_state_data(uint64_t *cpu_state_len)
> > > {
> > > FadumpRegSaveAreaHeader reg_save_hdr;
> > > - FadumpRegEntry *reg_entries;
> > > + g_autofree FadumpRegEntry *reg_entries;
> >
> > g_autofree pointers have to be NULL-initialized. I don't remember why,
> > likely CPP warnings.
>
> Ah, see for example commit c8f48b120b3:
>
> As mentioned in docs/devel/style.rst "Automatic memory deallocation":
>
> * Variables declared with g_auto* MUST always be initialized,
> otherwise the cleanup function will use uninitialized stack memory
>
> and for full context, commit 821f2967562 ("docs: document use of
> automatic cleanup functions in glib").
Hi Philippe,
Thanks for fix and explaination.
I'll send out v2 soon.
~Shivang.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-28 7:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-28 6:58 [PATCH 1/2] hw/ppc: Fix missing return on allocation failure Shivang Upadhyay
2025-10-28 6:58 ` [PATCH 2/2] hw/ppc: Fix memory leak in get_cpu_state_data() Shivang Upadhyay
2025-10-28 7:12 ` Philippe Mathieu-Daudé
2025-10-28 7:30 ` Philippe Mathieu-Daudé
2025-10-28 7:36 ` Shivang Upadhyay
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).