f7153f0
--- xen-4.6.1/tools/qemu-xen-traditional/hw/fw_cfg.c.orig	2016-01-04 15:35:42.000000000 +0000
f7153f0
+++ xen-4.6.1/tools/qemu-xen-traditional/hw/fw_cfg.c	2016-03-06 16:42:33.464296362 +0000
f7153f0
@@ -54,11 +54,15 @@
f7153f0
 static void fw_cfg_write(FWCfgState *s, uint8_t value)
f7153f0
 {
f7153f0
     int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
f7153f0
-    FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
f7153f0
+    FWCfgEntry *e = (s->cur_entry == FW_CFG_INVALID) ? NULL :
f7153f0
+                     &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
f7153f0
 
f7153f0
     FW_CFG_DPRINTF("write %d\n", value);
f7153f0
 
f7153f0
-    if (s->cur_entry & FW_CFG_WRITE_CHANNEL && s->cur_offset < e->len) {
f7153f0
+    if (s->cur_entry & FW_CFG_WRITE_CHANNEL
f7153f0
+        && e != NULL
f7153f0
+        && e->callback
f7153f0
+        && s->cur_offset < e->len) {
f7153f0
         e->data[s->cur_offset++] = value;
f7153f0
         if (s->cur_offset == e->len) {
f7153f0
             e->callback(e->callback_opaque, e->data);
f7153f0
@@ -88,7 +92,8 @@
f7153f0
 static uint8_t fw_cfg_read(FWCfgState *s)
f7153f0
 {
f7153f0
     int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
f7153f0
-    FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
f7153f0
+    FWCfgEntry *e = (s->cur_entry == FW_CFG_INVALID) ? NULL :
f7153f0
+                    &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
f7153f0
     uint8_t ret;
f7153f0
 
f7153f0
     if (s->cur_entry == FW_CFG_INVALID || !e->data || s->cur_offset >= e->len)