[PATCH] irqchip/riscv-imsic: Fix MMIO regset lookup loop bound

Pengpeng Hou pengpeng at iscas.ac.cn
Fri Jul 17 20:51:41 PDT 2026


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 at iscas.ac.cn>
---
 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




More information about the linux-riscv mailing list