Skip to contentSkip to conversation

ppc/pnv: Fix uninitialized MpiplProcDumpArea struct

PATCH In review Shivang Upadhyay 2 participants 3 messages May 8

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc/pnv: Fix uninitialized MpiplProcDumpArea struct

Fix Coverity CID 1658041 by using designated initializers to prevent uninitialized memory from being written to guest.

---
 hw/ppc/pnv.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
hw/ppc/pnv.c +4 -12
index 9ed918fa6a..c0afef8197 100644
@@ -838,18 +838,10 @@ static void pnv_reset(MachineState *machine, ResetType type)
          * crash
          */
 
-        MpiplProcDumpArea proc_area;
-
-        proc_area.version = PROC_DUMP_AREA_VERSION_P9;
-        proc_area.thread_size = cpu_to_be32(sizeof(MpiplPreservedCPUState));
-
-        /* These are to be allocated & assigned by the firmware */
-        proc_area.alloc_addr = 0;
-        proc_area.alloc_size = 0;
-
-        /* These get assigned after crash, when QEMU preserves the registers */
-        proc_area.dest_addr = 0;
-        proc_area.act_size = 0;
+        MpiplProcDumpArea proc_area = {
+            .version = PROC_DUMP_AREA_VERSION_P9,
+            .thread_size = cpu_to_be32(sizeof(MpiplPreservedCPUState)),
+        };
 
         cpu_physical_memory_write(PROC_DUMP_AREA_OFF, &proc_area,
                 sizeof(proc_area));
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Shivang Upadhyay

Fix Coverity CID 1658041 by using designated initializers to prevent uninitialized memory from being written to guest.

---
  hw/ppc/pnv.c | 16 ++++------------
  1 file changed, 4 insertions(+), 12 deletions(-)
hw/ppc/pnv.c +0 -7
index 9ed918fa6a..c0afef8197 100644
@@ -838,18 +838,10 @@ static void pnv_reset(MachineState *machine, ResetType type)
           * crash
           */
 
-        MpiplProcDumpArea proc_area;
-
-        proc_area.version = PROC_DUMP_AREA_VERSION_P9;
-        proc_area.thread_size = cpu_to_be32(sizeof(MpiplPreservedCPUState));
-
-        /* These are to be allocated & assigned by the firmware */
-        proc_area.alloc_addr = 0;

hw/ppc/pnv.c static void pnv_reset(MachineState *machine, ResetType type) · line 845

Quoted 10 lines
hw/ppc/pnv.c +4 -5
-        proc_area.alloc_size = 0;
-
-        /* These get assigned after crash, when QEMU preserves the registers */
-        proc_area.dest_addr = 0;
-        proc_area.act_size = 0;
+        MpiplProcDumpArea proc_area = {
+            .version = PROC_DUMP_AREA_VERSION_P9,
+            .thread_size = cpu_to_be32(sizeof(MpiplPreservedCPUState)),
+        };
 

Thanks for the fix, shivang.

- Aditya G