Skip to contentSkip to conversation

ppc/amigaone: Free allocated struct

PATCH In review BALATON Zoltan 2 participants 2 messages Oct 22, 2025 – Oct 23, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc/amigaone: Free allocated struct

In create_bd_info function a bd_info struct is allocated but never freed. Mark it g_autofree to avoid leaking it.

Fixes 34f053d86b (ppc/amigaone: Add kernel and initrd support)

Resolves: Coverity CID 1641398

---
 hw/ppc/amigaone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/amigaone.c +1 -1
index 12279f42bc..47fb016b4a 100644
@@ -221,7 +221,7 @@ struct bd_info {
 
 static void create_bd_info(hwaddr addr, ram_addr_t ram_size)
 {
-    struct bd_info *bd = g_new0(struct bd_info, 1);
+    g_autofree struct bd_info *bd = g_new0(struct bd_info, 1);
 
     bd->bi_memsize =    cpu_to_be32(ram_size);
     bd->bi_flashstart = cpu_to_be32(PROM_ADDR);
Signature · 1 line
2.41.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · BALATON Zoltan

In create_bd_info function a bd_info struct is allocated but never freed. Mark it g_autofree to avoid leaking it.

Fixes 34f053d86b (ppc/amigaone: Add kernel and initrd support)

Resolves: Coverity CID 1641398

---
  hw/ppc/amigaone.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/amigaone.c +0 -0
index 12279f42bc..47fb016b4a 100644

hw/ppc/amigaone.c struct bd_info { · line 225

Quoted 6 lines
hw/ppc/amigaone.c +1 -1
@@ -221,7 +221,7 @@ struct bd_info {
 
  static void create_bd_info(hwaddr addr, ram_addr_t ram_size)
  {
-    struct bd_info *bd = g_new0(struct bd_info, 1);
+    g_autofree struct bd_info *bd = g_new0(struct bd_info, 1);
 
Quoted 2 lines
hw/ppc/amigaone.c +0 -0
      bd->bi_memsize =    cpu_to_be32(ram_size);
      bd->bi_flashstart = cpu_to_be32(PROM_ADDR);