Skip to content

Commit 6eabf65

Browse files
charlie-rivosKAGA-KOKO
authored andcommitted
irqchip/sifive-plic: Return error code on failure
Set error to -ENOMEM if kcalloc() fails or if irq_domain_add_linear() fails inside of plic_probe() instead of returning 0. Fixes: 4d936f1 ("irqchip/sifive-plic: Probe plic driver early for Allwinner D1 platform") Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Charlie Jenkins <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Alexandre Ghiti <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/20240903-correct_error_codes_sifive_plic-v1-1-d929b79663a2@rivosinc.com Closes: https://lore.kernel.org/r/[email protected]/
1 parent 4a1361e commit 6eabf65

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/irqchip/irq-sifive-plic.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,10 @@ static int plic_probe(struct fwnode_handle *fwnode)
626626

627627
handler->enable_save = kcalloc(DIV_ROUND_UP(nr_irqs, 32),
628628
sizeof(*handler->enable_save), GFP_KERNEL);
629-
if (!handler->enable_save)
629+
if (!handler->enable_save) {
630+
error = -ENOMEM;
630631
goto fail_cleanup_contexts;
632+
}
631633
done:
632634
for (hwirq = 1; hwirq <= nr_irqs; hwirq++) {
633635
plic_toggle(handler, hwirq, 0);
@@ -639,8 +641,10 @@ static int plic_probe(struct fwnode_handle *fwnode)
639641

640642
priv->irqdomain = irq_domain_create_linear(fwnode, nr_irqs + 1,
641643
&plic_irqdomain_ops, priv);
642-
if (WARN_ON(!priv->irqdomain))
644+
if (WARN_ON(!priv->irqdomain)) {
645+
error = -ENOMEM;
643646
goto fail_cleanup_contexts;
647+
}
644648

645649
/*
646650
* We can have multiple PLIC instances so setup global state

0 commit comments

Comments
 (0)