Skip to content

Commit

Permalink
mac_dbdma: always initialize channel field in DBDMA_channel
Browse files Browse the repository at this point in the history
dbdma_from_ch() uses channel field to return the right DBDMA object.
Previous code was working if guest OS was only using registered DMA channels.
However, it lead to QEMU crashes if guest OS was using unregistered DMA channels.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
  • Loading branch information
hpoussin authored and dgibson committed Nov 30, 2015
1 parent 7144875 commit 7f0d763
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hw/misc/macio/mac_dbdma.c
Expand Up @@ -557,7 +557,6 @@ void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq,
DBDMA_DPRINTF("DBDMA_register_channel 0x%x\n", nchan);

ch->irq = irq;
ch->channel = nchan;
ch->rw = rw;
ch->flush = flush;
ch->io.opaque = opaque;
Expand Down Expand Up @@ -753,6 +752,7 @@ void* DBDMA_init (MemoryRegion **dbdma_mem)
for (i = 0; i < DBDMA_CHANNELS; i++) {
DBDMA_io *io = &s->channels[i].io;
qemu_iovec_init(&io->iov, 1);
s->channels[i].channel = i;
}

memory_region_init_io(&s->mem, NULL, &dbdma_ops, s, "dbdma", 0x1000);
Expand Down

0 comments on commit 7f0d763

Please sign in to comment.