aboutsummaryrefslogtreecommitdiff
path: root/hw/audio/cs4231a.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2018-03-16 10:51:31 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2018-03-26 14:37:13 +0200
commitc9073238fcb647644b329705ad54734ad1f0b1a3 (patch)
tree2fffdfbc57aeae407c4fce428ddbcf7ce3a15f16 /hw/audio/cs4231a.c
parentb3da551389c86ce214d5418c174134c3e1c838ab (diff)
hw/audio: Fix crashes when devices are used on ISA bus without DMA
The cs4231a, gus and sb16 sound cards crash QEMU when the user tries to instantiate them on a machine with DMA-less ISA bus (for example with "qemu-system-mips64el -M mips -device sb16"). Add proper checks to the realize functions to avoid the crashes. Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1521193892-15552-4-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/audio/cs4231a.c')
-rw-r--r--hw/audio/cs4231a.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
index 096e8e98d7..aaebec1839 100644
--- a/hw/audio/cs4231a.c
+++ b/hw/audio/cs4231a.c
@@ -28,6 +28,7 @@
#include "hw/isa/isa.h"
#include "hw/qdev.h"
#include "qemu/timer.h"
+#include "qapi/error.h"
/*
Missing features:
@@ -663,8 +664,13 @@ static void cs4231a_realizefn (DeviceState *dev, Error **errp)
CSState *s = CS4231A (dev);
IsaDmaClass *k;
- isa_init_irq (d, &s->pic, s->irq);
s->isa_dma = isa_get_dma(isa_bus_from_device(d), s->dma);
+ if (!s->isa_dma) {
+ error_setg(errp, "ISA controller does not support DMA");
+ return;
+ }
+
+ isa_init_irq(d, &s->pic, s->irq);
k = ISADMA_GET_CLASS(s->isa_dma);
k->register_channel(s->isa_dma, s->dma, cs_dma_read, s);