diff --git a/hw/ide/core.c b/hw/ide/core.c index f76f7e5234bc648997f4777fa1e33e014c27778d..8105187f497ff8380259d02f2287aea7c78b9ab1 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -718,6 +718,7 @@ void ide_cancel_dma_sync(IDEState *s) * whole DMA operation will be submitted to disk with a single * aio operation with preadv/pwritev. */ + assert(s->blk); if (s->bus->dma->aiocb) { trace_ide_cancel_dma_sync_remaining(); blk_drain(s->blk); diff --git a/hw/ide/pci.c b/hw/ide/pci.c index b50091b615cbc42d6bacba83132f7a585458a7a6..b47e675456fd7091a3a54f0d648b065f058e5640 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -295,7 +295,10 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) /* Ignore writes to SSBM if it keeps the old value */ if ((val & BM_CMD_START) != (bm->cmd & BM_CMD_START)) { if (!(val & BM_CMD_START)) { - ide_cancel_dma_sync(idebus_active_if(bm->bus)); + IDEState *s = idebus_active_if(bm->bus); + if (s->blk) { + ide_cancel_dma_sync(s); + } bm->status &= ~BM_STATUS_DMAING; } else { bm->cur_addr = bm->addr; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index de0fae10ab9c6ac37b78fa8df717223fc094c6c9..df5a2c329493204592bceca6ee63e4c39594baf3 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -253,6 +253,9 @@ static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change) PCIBus *bus; for (;;) { bus = pci_get_bus(pci_dev); + if (!bus) { + return; + } irq_num = bus->map_irq(pci_dev, irq_num); if (bus->set_irq) break;