From: Ian Jackson Date: Mon, 7 Dec 2009 12:25:54 +0000 (+0000) Subject: passthrough: Fix no_wb not to crash on unknown registers X-Git-Tag: xen-4.0.0-rc1~7 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9297e6402f6aa1b52e5577edc875eb2d2163baeb;p=qemu-xen-4.6-testing.git passthrough: Fix no_wb not to crash on unknown registers e2b98415256cb264bc25e6df539ec0dc9d1b85b0 broke things sometimes: If pt_find_reg_grp() fails and returns NULL, it will jump to out:, but at this time reg is still NULL (pt_find_reg() is not reached) which leads to a NULL dereference. This patch fixes it. Submitted-By: Qing He Signed-off-by: Ian Jackson --- diff --git a/hw/pass-through.c b/hw/pass-through.c index b125d7222..e7bd38602 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -1556,7 +1556,7 @@ static void pt_pci_write_config(PCIDevice *d, uint32_t address, uint32_t val, val >>= ((address & 3) << 3); out: - if (!reg->no_wb) { + if (!(reg && reg->no_wb)) { /* unknown regs are passed through */ ret = pci_write_block(pci_dev, address, (uint8_t *)&val, len); if (!ret)