[PATCH 1/6] lib: sbi_irqchip: Check full range for existing handlers in sbi_irqchip_register_handler()

Anup Patel anup.patel at oss.qualcomm.com
Wed Apr 22 22:23:34 PDT 2026


Currently, the sbi_irqchip_register_handler() only checks the first and the
last hardware interrupt for existing handlers which is buggy because there
may be existing handlers between the first and the last hardware interrupt.

Fixes: 0ab0c470d588 ("lib: sbi_irqchip: Allow registering interrupt handlers")
Signed-off-by: Anup Patel <anup.patel at oss.qualcomm.com>
---
 lib/sbi/sbi_irqchip.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c
index f0744830..503958e1 100644
--- a/lib/sbi/sbi_irqchip.c
+++ b/lib/sbi/sbi_irqchip.c
@@ -149,12 +149,11 @@ int sbi_irqchip_register_handler(struct sbi_irqchip_device *chip,
 	    chip->num_hwirq <= (first_hwirq + num_hwirq - 1))
 		return SBI_EBAD_RANGE;
 
-	h = sbi_irqchip_find_handler(chip, first_hwirq);
-	if (h)
-		return SBI_EALREADY;
-	h = sbi_irqchip_find_handler(chip, first_hwirq + num_hwirq - 1);
-	if (h)
-		return SBI_EALREADY;
+	for (i = first_hwirq; i < (first_hwirq + num_hwirq); i++) {
+		h = sbi_irqchip_find_handler(chip, i);
+		if (h)
+			return SBI_EALREADY;
+	}
 
 	h = sbi_zalloc(sizeof(*h));
 	if (!h)
-- 
2.43.0




More information about the opensbi mailing list