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 <[email protected]>
Cc: Harsh Prateek Bora <[email protected]>
Link: https://lore.kernel.org/qemu-devel/ CAFEAcA_Bm52bkPi9MH_uugXRR5fj48RtpbOnPNFQtbX=7mz...@mail.gmail.com/
Reported-by: Peter Maydell <[email protected]>
Suggested-by: Peter Maydell <[email protected]>
Signed-off-by: Shivang Upadhyay <[email protected]>
---
  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").

Reply via email to