Skip to contentSkip to conversation

pseries: Fix initialization of sPAPREnvironment structure

PATCH New David Gibson 1 participant 1 message Nov 2, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pseries: Fix initialization of sPAPREnvironment structure

Since we added PCI support to the pseries machine, we include a qlist of PCI host bridges in the sPAPREnvironment structure. However this list was never properly initialized it. Somehow we got away with this until some other recent change broke it, and we now segfault immediately on startup.

This patch adds the required QLIST_INIT(), and while we're at it makes sure we initialize the rest of the sPAPREnvironment structure to 0, to avoid future nasty surprises.

---
 hw/spapr.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
hw/spapr.c +3 -1
index bdaa938..40cfc9b 100644
@@ -407,7 +407,9 @@ static void ppc_spapr_init(ram_addr_t ram_size,
     long pteg_shift = 17;
     char *filename;
 
-    spapr = g_malloc(sizeof(*spapr));
+    spapr = g_malloc0(sizeof(*spapr));
+    QLIST_INIT(&spapr->phbs);
+
     cpu_ppc_hypercall = emulate_spapr_hypercall;
 
     /* Allocate RMA if necessary */
Signature · 1 line
1.7.7