hw/i386/pc: fix possible segment fault for port92_write
PATCH v2 1/2 hw/i386/pc: fix possible segment fault for port92_write
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 <[email protected]>
--- hw/i386/pc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
hw/i386/pc.c +3 -1
@@ -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 (); }
Signature · 1 line
1.7.2.5
PATCH v2 2/2 hw/i386/pc: check a20_out in port92_realizefn
as suggested by Andreas
Signed-off-by liguang <[email protected]>
--- hw/i386/pc.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
hw/i386/pc.c +5 -0
@@ -503,6 +503,11 @@ static void port92_realizefn(DeviceState *dev, Error **err)ISADevice *isadev =ISA_DEVICE (dev);Port92State *s =PORT92 (dev); +if (s->a20_out ==NULL ) { +error_setg (err,"Can't create port92 device.\n" ); +return ; + } +memory_region_init_io (&s->io, &port92_ops, s,"port92" ,1 );isa_register_ioport (isadev, &s->io,0x92 );
Signature · 1 line
1.7.2.5