From 0d81a78ec54be2f7c62906b1aa945240ce519c6b Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Thu, 23 Apr 2026 10:53:34 +0530 Subject: [PATCH] lib: sbi_irqchip: Check full range for existing handlers in sbi_irqchip_register_handler() 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 Link: https://lore.kernel.org/r/20260423052339.356900-2-anup.patel@oss.qualcomm.com Signed-off-by: Anup Patel --- 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)