[PATCH] irqchip/riscv-imsic: Fix MMIO regset lookup loop bound
From: GUO Ren (XuanTie)
Date: Fri Sep 04 2026 - 11:06:24 EST
The nr_mmios is the number of entries in the MMIO resource array, while
j is the index used to iterate over the array. Testing nr_mmios directly
makes the loop condition permanently true whenever at least one MMIO
region exists.
So, change
for (j = 0; nr_mmios; j++) {
to
for (j = 0; j < nr_mmios; j++) {
Fixes: 21a8f8a0eb35 ("irqchip: Add RISC-V incoming MSI controller early driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: GUO Ren (XuanTie) <guoren@xxxxxxxxxx>
---
This patch fixes an out-of-bounds access in the RISC-V IMSIC MMIO
resource lookup.
---
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 b8d1bbbf42f7..008dfcf343e5 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;
---
base-commit: bc35965f6940a9bf834d54187b6088b8eb09206d
change-id: 20260904-nr_mmios-868e369de25b
Best regards,
--
GUO Ren (XuanTie) <guoren@xxxxxxxxxx>