Skip to content

Commit dc08030

Browse files
charlie-rivosgregkh
authored andcommitted
irqchip/sifive-plic: Return error code on failure
commit 6eabf65 upstream. 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 <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Anup Patel <anup@brainfault.org> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/20240903-correct_error_codes_sifive_plic-v1-1-d929b79663a2@rivosinc.com Closes: https://lore.kernel.org/r/202409031122.yBh8HrxA-lkp@intel.com/ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fa5f7b9 commit dc08030

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/irqchip/irq-sifive-plic.c

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

579579
handler->enable_save = kcalloc(DIV_ROUND_UP(nr_irqs, 32),
580580
sizeof(*handler->enable_save), GFP_KERNEL);
581-
if (!handler->enable_save)
581+
if (!handler->enable_save) {
582+
error = -ENOMEM;
582583
goto fail_cleanup_contexts;
584+
}
583585
done:
584586
for (hwirq = 1; hwirq <= nr_irqs; hwirq++) {
585587
plic_toggle(handler, hwirq, 0);
@@ -591,8 +593,10 @@ static int plic_probe(struct fwnode_handle *fwnode)
591593

592594
priv->irqdomain = irq_domain_add_linear(to_of_node(fwnode), nr_irqs + 1,
593595
&plic_irqdomain_ops, priv);
594-
if (WARN_ON(!priv->irqdomain))
596+
if (WARN_ON(!priv->irqdomain)) {
597+
error = -ENOMEM;
595598
goto fail_cleanup_contexts;
599+
}
596600

597601
/*
598602
* We can have multiple PLIC instances so setup global state

0 commit comments

Comments
 (0)