hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES
PATCH 1/1 hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES
The num-lines property of the TYPE_OR_GATE device sets the number of input lines it has. An assert() in or_irq_realize() restricts this to the maximum supported by the implementation. However we got the condition in the assert wrong: it should be using <=, because num-lines == MAX_OR_LINES is permitted, and means that all entries from 0 to MAX_OR_LINES-1 in the s->levels[] array are used.
We didn't notice this previously because no user has so far needed that many input lines.
--- hw/core/or-irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/or-irq.c +1 -1
@@ -58,7 +58,7 @@ static void or_irq_realize(DeviceState *dev, Error **errp) {qemu_or_irq *s =OR_IRQ (dev); -assert (s->num_lines <MAX_OR_LINES ); +assert (s->num_lines <=MAX_OR_LINES );qdev_init_gpio_in (dev, or_irq_handler, s->num_lines); }
Signature · 1 line
2.20.1
Quoted 23 lines · Peter Maydell
The num-lines property of the
TYPE_OR_GATEdevice sets the number of input lines it has. Anassert()inor_irq_realize()restricts this to the maximum supported by the implementation. However we got the condition in the assert wrong: it should be using <=, because num-lines ==MAX_OR_LINESis permitted, and means that all entries from 0 to MAX_OR_LINES-1 in the s->levels[] array are used.We didn't notice this previously because no user has so far needed that many input lines.
Reported-by Guenter Roeck <[email protected]>Signed-off-by Peter Maydell <[email protected]>--- hw/core/or-irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/core/or-irq.c +0
-0
hw/core/or-irq.c static void or_irq_realize(DeviceState *dev, Error **errp) · line 64
Quoted 8 lines
hw/core/or-irq.c +1
-1@@ -58,7 +58,7 @@ static void or_irq_realize(DeviceState *dev, Error **errp) {qemu_or_irq *s =OR_IRQ (dev); -assert (s->num_lines <MAX_OR_LINES ); +assert (s->num_lines <=MAX_OR_LINES );qdev_init_gpio_in (dev, or_irq_handler, s->num_lines); }
Quoted 8 lines · Peter Maydell
The num-lines property of the
TYPE_OR_GATEdevice sets the number of input lines it has. Anassert()inor_irq_realize()restricts this to the maximum supported by the implementation. However we got the condition in the assert wrong: it should be using <=, because num-lines ==MAX_OR_LINESis permitted, and means that all entries from 0 to MAX_OR_LINES-1 in the s->levels[] array are used.
Quoted 5 lines
We didn't notice this previously because no user has so far needed that many input lines.
Reported-by Guenter Roeck <[email protected]>Signed-off-by Peter Maydell <[email protected]>
Quoted 18 lines
--- hw/core/or-irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/core/or-irq.c +1
-1@@ -58,7 +58,7 @@ static void or_irq_realize(DeviceState *dev, Error **errp) {qemu_or_irq *s =OR_IRQ (dev); -assert (s->num_lines <MAX_OR_LINES ); +assert (s->num_lines <=MAX_OR_LINES );qdev_init_gpio_in (dev, or_irq_handler, s->num_lines); }