[PATCH] irqchip/sifive-plic: Fix error handling of of_property_read_u32

Alexandre Ghiti alex at ghiti.fr
Fri Mar 22 10:08:55 PDT 2024


Hi Qingfang,

On 22/03/2024 10:00, Qingfang Deng wrote:
> From: Qingfang Deng <qingfang.deng at siflower.com.cn>
>
> nr_irqs will not be initialized if of_property_read_u32 returns an
> error. Check the error first.
>
> Fixes: 8237f8bc4f6e ("irqchip: add a SiFive PLIC driver")
> Signed-off-by: Qingfang Deng <qingfang.deng at siflower.com.cn>
> ---
>   drivers/irqchip/irq-sifive-plic.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
> index 5b7bc4fd9517..f436b61d74b0 100644
> --- a/drivers/irqchip/irq-sifive-plic.c
> +++ b/drivers/irqchip/irq-sifive-plic.c
> @@ -428,8 +428,11 @@ static int __init __plic_init(struct device_node *node,
>   		goto out_free_priv;
>   	}
>   
> +	error = of_property_read_u32(node, "riscv,ndev", &nr_irqs);
> +	if (error)
> +		goto out_iounmap;
> +
>   	error = -EINVAL;
> -	of_property_read_u32(node, "riscv,ndev", &nr_irqs);
>   	if (WARN_ON(!nr_irqs))
>   		goto out_iounmap;
>   


You can add:

Reviewed-by: Alexandre Ghiti <alexghiti at rivosinc.com>

Thanks,

Alex




More information about the linux-riscv mailing list