Index: sys/arm/arm/gic.c =================================================================== --- sys/arm/arm/gic.c +++ sys/arm/arm/gic.c @@ -1438,18 +1438,18 @@ found = true; /* Check this range is valid */ - for (end_irq = irq; end_irq != irq + count - 1; end_irq++) { - /* No free interrupts */ - if (end_irq == sc->sc_spi_end) { + for (end_irq = irq; end_irq < irq + count; end_irq++) { + KASSERT((psc->gic_irqs[end_irq].gi_flags & GI_FLAG_MSI)!= 0, + ("%s: Non-MSI interrupt found", __func__)); + + /* Range does not fit */ + if (end_irq >= sc->sc_spi_end) { found = false; break; } - KASSERT((psc->gic_irqs[irq].gi_flags & GI_FLAG_MSI)!= 0, - ("%s: Non-MSI interrupt found", __func__)); - /* This is already used */ - if ((psc->gic_irqs[irq].gi_flags & GI_FLAG_MSI_USED) == + if ((psc->gic_irqs[end_irq].gi_flags & GI_FLAG_MSI_USED) == GI_FLAG_MSI_USED) { found = false; break;