| Message ID | 20260820134431.167336-1-heinrich.schuchardt@canonical.com |
|---|---|
| State | Accepted |
| Headers | show |
| Series | [1/1] lib: sbi_irqchip: error handling in sbi_irqchip_raw_handler_default() | expand |
On Thu, Aug 20, 2026 at 7:14 PM Heinrich Schuchardt <heinrich.schuchardt@canonical.com> wrote: > > sbi_irqchip_find_handler() may return NULL. > Check the return value before dereferencing. > > Addresses-Coverity-ID: 1677408 Dereference null return value > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> LGTM. Reviewed-by: Anup Patel <anup@brainfault.org> Applied this patch to the riscv/opensbi repo. Thanks, Anup > --- > lib/sbi/sbi_irqchip.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c > index b490a3ad..1664bd2d 100644 > --- a/lib/sbi/sbi_irqchip.c > +++ b/lib/sbi/sbi_irqchip.c > @@ -185,6 +185,9 @@ int sbi_irqchip_raw_handler_default(struct sbi_irqchip_device *chip, u32 hwirq) > return SBI_EINVAL; > > h = sbi_irqchip_find_handler(chip, hwirq); > + if (!h) > + return SBI_EINVAL; > + > if (h->callback) > rc = h->callback(hwirq, h->priv); > > -- > 2.53.0 >
diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c index b490a3ad..1664bd2d 100644 --- a/lib/sbi/sbi_irqchip.c +++ b/lib/sbi/sbi_irqchip.c @@ -185,6 +185,9 @@ int sbi_irqchip_raw_handler_default(struct sbi_irqchip_device *chip, u32 hwirq) return SBI_EINVAL; h = sbi_irqchip_find_handler(chip, hwirq); + if (!h) + return SBI_EINVAL; + if (h->callback) rc = h->callback(hwirq, h->priv);
sbi_irqchip_find_handler() may return NULL. Check the return value before dereferencing. Addresses-Coverity-ID: 1677408 Dereference null return value Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> --- lib/sbi/sbi_irqchip.c | 3 +++ 1 file changed, 3 insertions(+)