mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "GUO Ren (XuanTie)" <guoren@kernel.org>
To: "Anup Patel" <anup@brainfault.org>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Radu Rendec" <radu@rendec.net>, "Paul Walmsley" <pjw@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	"Björn Töpel" <bjorn@rivosinc.com>
Cc: Anup Patel <apatel@ventanamicro.com>,
	linux-riscv@lists.infradead.org,  linux-kernel@vger.kernel.org,
	stable@vger.kernel.org,  "GUO Ren (XuanTie)" <guoren@kernel.org>
Subject: [PATCH] irqchip/riscv-imsic: Fix MMIO regset lookup loop bound
Date: Fri, 04 Sep 2026 14:31:38 +0000	[thread overview]
Message-ID: <20260904-nr_mmios-v1-1-3a19dc74fab8@kernel.org> (raw)

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@vger.kernel.org
Signed-off-by: GUO Ren (XuanTie) <guoren@kernel.org>
---
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@kernel.org>


             reply	other threads:[~2026-09-04 14:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 14:31 GUO Ren (XuanTie) [this message]
2026-09-04 14:38 ` Guo Ren
  -- strict thread matches above, loose matches on Subject: below --
2026-07-18  3:51 Pengpeng Hou
2026-07-20  3:31 ` Anup Patel
2026-07-20  3:44 ` Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260904-nr_mmios-v1-1-3a19dc74fab8@kernel.org \
    --to=guoren@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=apatel@ventanamicro.com \
    --cc=bjorn@rivosinc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=radu@rendec.net \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®