[PATCH] irqchip/riscv-imsic: Fix MMIO regset lookup loop bound
From: Pengpeng Hou
Date: Fri Jul 17 2026 - 23:52:11 EST
nr_mmios is the number of elements in the MMIO resource arrays, while j is
the index that advances through them. The loop currently tests the nonzero
count on every iteration. If no region contains reloff, it reads past mmios
before reaching the existing not-found check.
Compare j with nr_mmios. This preserves successful lookups and lets the
not-found path handle an offset beyond the listed regions.
Fixes: 21a8f8a0eb35 ("irqchip: Add RISC-V incoming MSI controller early driver")
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
drivers/irqchip/irq-riscv-imsic-state.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c
index b8d1bbbf42f73..008dfcf343e53 100644
--- a/drivers/irqchip/irq-riscv-imsic-state.c
+++ b/drivers/irqchip/irq-riscv-imsic-state.c
@@ -896,7 +896,7 @@ int __init imsic_setup_state(struct fwnode_handle *fwnode, void *opaque)
index = nr_mmios;
reloff = i * BIT(global->guest_index_bits) *
IMSIC_MMIO_PAGE_SZ;
- for (j = 0; nr_mmios; j++) {
+ for (j = 0; j < nr_mmios; j++) {
if (reloff < resource_size(&mmios[j])) {
index = j;
break;
--
2.43.0