Patchwork [v2,1/2] hw/i386/pc: fix possible segment fault for port92_write

login
register
mail settings
Submitter liguang
Date March 28, 2013, 9:03 a.m.
Message ID <1364461382-20359-1-git-send-email-lig.fnst@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/231955/
State New
Headers show

Comments

liguang - March 28, 2013, 9:03 a.m.
e.g.
$qemu-system-x86_64 -device port92
will report segment fault,
for port92_write try a un-allocated
assignment for a20_out.
so check before this assignment.

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 hw/i386/pc.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 09fb728..b881314 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -444,7 +444,9 @@  static void port92_write(void *opaque, hwaddr addr, uint64_t val,
 
     DPRINTF("port92: write 0x%02x\n", val);
     s->outport = val;
-    qemu_set_irq(*s->a20_out, (val >> 1) & 1);
+    if (s->a20_out) {
+        qemu_set_irq(*s->a20_out, (val >> 1) & 1);
+    }
     if (val & 1) {
         qemu_system_reset_request();
     }