hw/audio/cs4231a: fix assertion error in isa_bus_get_irq
PATCH 1/1 hw/audio/cs4231a: fix assertion error in isa_bus_get_irq
This patch fixes an assertion error in isa_bus_get_irq() in /hw/isa/isa-bus.c by adding a constraint to the irq property.
--- hw/audio/cs4231a.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/audio/cs4231a.c +4 -0
@@ -682,6 +682,10 @@ static void cs4231a_realizefn (DeviceState *dev, Error **errp)return ; } +if (s->irq >=ISA_NUM_IRQS ) { +error_setg (errp,"Invalid IRQ %d (max %d)" , s->irq,ISA_NUM_IRQS ); +return ; + } s->pic =isa_bus_get_irq (bus, s->irq); k =ISADMA_GET_CLASS (s->isa_dma); k->register_channel (s->isa_dma, s->dma, cs_dma_read, s);
Signature · 1 line
2.34.1
Hi Zheng,
Quoted 2 lines · Zheng Huang
This patch fixes an assertion error in
isa_bus_get_irq()in /hw/isa/isa-bus.c by adding a constraint to the irq property.
Can you provide a reproducer to trigger that?
Quoted 21 lines
Signed-off-by Zheng Huang <[email protected]>--- hw/audio/cs4231a.c | 4 ++++ 1 file changed, 4 insertions(+)hw/audio/cs4231a.c +4
-0@@ -682,6 +682,10 @@ static void cs4231a_realizefn (DeviceState *dev, Error **errp)return ; } +if (s->irq >=ISA_NUM_IRQS ) { +error_setg (errp,"Invalid IRQ %d (max %d)" , s->irq,ISA_NUM_IRQS ); +return ; + } s->pic =isa_bus_get_irq (bus, s->irq); k =ISADMA_GET_CLASS (s->isa_dma); k->register_channel (s->isa_dma, s->dma, cs_dma_read, s);
Hi Philippe,
Quoted 8 lines · Philippe Mathieu-Daudé
Hi Zheng,
Quoted 2 lines · Zheng Huang
This patch fixes an assertion error in
isa_bus_get_irq()in /hw/isa/isa-bus.c by adding a constraint to the irq property.Can you provide a reproducer to trigger that?
Sure, this bug occures when start qemu with:
```bash qemu-system-x86_64 -display none -machine accel=qtest -m 64 -M pc -nodefaults -audiodev none,id=snd0 -nodefaults -device cs4231a,audiodev=snd0,irq=17 ```
and error message following:
qemu-system-x86_64: ../hw/isa/isa-bus.c:84: qemu_irq isa_bus_get_irq(ISABus *, unsigned int): Assertion `irqnum < ISA_NUM_IRQS' failed.
Besides, pls refer to patch v2, in which I updated the constraint.
Quoted 21 lines
Quoted 20 lines
Signed-off-by Zheng Huang <[email protected]>---
hw/audio/cs4231a.c| 4 ++++1 file changed, 4 insertions(+)hw/audio/cs4231a.c +3
-0@@ -682,6 +682,10 @@ static void cs4231a_realizefn (DeviceState *dev, Error **errp) return; } + if (s->irq >= ISA_NUM_IRQS) { + error_setg(errp, "Invalid IRQ %d (max %d)", s->irq, ISA_NUM_IRQS); + return; + } s->pic = isa_bus_get_irq(bus, s->irq); k = ISADMA_GET_CLASS(s->isa_dma); k->register_channel(s->isa_dma, s->dma, cs_dma_read, s);