qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/audio/cs4231a: fix assertion error in isa_bus_get_irq
@ 2025-05-09 11:15 Zheng Huang
  2025-05-09 11:28 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 3+ messages in thread
From: Zheng Huang @ 2025-05-09 11:15 UTC (permalink / raw)
  To: qemu-devel

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.

Signed-off-by: Zheng Huang <hz1624917200@gmail.com>
---
 hw/audio/cs4231a.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
index 5a9be80ba3..d390da4c37 100644
--- a/hw/audio/cs4231a.c
+++ b/hw/audio/cs4231a.c
@@ -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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hw/audio/cs4231a: fix assertion error in isa_bus_get_irq
  2025-05-09 11:15 [PATCH] hw/audio/cs4231a: fix assertion error in isa_bus_get_irq Zheng Huang
@ 2025-05-09 11:28 ` Philippe Mathieu-Daudé
  2025-05-09 11:37   ` Zheng Huang
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-09 11:28 UTC (permalink / raw)
  To: Zheng Huang, qemu-devel

Hi Zheng,

On 9/5/25 13:15, Zheng Huang wrote:
> 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?

> 
> Signed-off-by: Zheng Huang <hz1624917200@gmail.com>
> ---
>   hw/audio/cs4231a.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
> index 5a9be80ba3..d390da4c37 100644
> --- a/hw/audio/cs4231a.c
> +++ b/hw/audio/cs4231a.c
> @@ -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);



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hw/audio/cs4231a: fix assertion error in isa_bus_get_irq
  2025-05-09 11:28 ` Philippe Mathieu-Daudé
@ 2025-05-09 11:37   ` Zheng Huang
  0 siblings, 0 replies; 3+ messages in thread
From: Zheng Huang @ 2025-05-09 11:37 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

Hi Philippe,

On 2025/5/9 19:28, Philippe Mathieu-Daudé wrote:
> Hi Zheng,
> 
> On 9/5/25 13:15, Zheng Huang wrote:
>> 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.

>>
>> Signed-off-by: Zheng Huang <hz1624917200@gmail.com>
>> ---
>>   hw/audio/cs4231a.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
>> index 5a9be80ba3..d390da4c37 100644
>> --- a/hw/audio/cs4231a.c
>> +++ b/hw/audio/cs4231a.c
>> @@ -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);
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-09 11:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-09 11:15 [PATCH] hw/audio/cs4231a: fix assertion error in isa_bus_get_irq Zheng Huang
2025-05-09 11:28 ` Philippe Mathieu-Daudé
2025-05-09 11:37   ` Zheng Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).