* [PATCH] irqchip/sifive-plic: Fix error handling of of_property_read_u32
@ 2024-03-22 9:00 Qingfang Deng
2024-03-22 17:08 ` Alexandre Ghiti
0 siblings, 1 reply; 3+ messages in thread
From: Qingfang Deng @ 2024-03-22 9:00 UTC (permalink / raw)
To: Thomas Gleixner, Palmer Dabbelt, Paul Walmsley, Albert Ou,
Atish Patra, linux-kernel, linux-riscv
Cc: Christoph Hellwig, Qingfang Deng
From: Qingfang Deng <qingfang.deng@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@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;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] irqchip/sifive-plic: Fix error handling of of_property_read_u32
2024-03-22 9:00 [PATCH] irqchip/sifive-plic: Fix error handling of of_property_read_u32 Qingfang Deng
@ 2024-03-22 17:08 ` Alexandre Ghiti
2024-03-25 20:45 ` Alexandre Ghiti
0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Ghiti @ 2024-03-22 17:08 UTC (permalink / raw)
To: Qingfang Deng, Thomas Gleixner, Palmer Dabbelt, Paul Walmsley,
Albert Ou, Atish Patra, linux-kernel, linux-riscv
Cc: Christoph Hellwig, Qingfang Deng
Hi Qingfang,
On 22/03/2024 10:00, Qingfang Deng wrote:
> From: Qingfang Deng <qingfang.deng@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@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@rivosinc.com>
Thanks,
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] irqchip/sifive-plic: Fix error handling of of_property_read_u32
2024-03-22 17:08 ` Alexandre Ghiti
@ 2024-03-25 20:45 ` Alexandre Ghiti
0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Ghiti @ 2024-03-25 20:45 UTC (permalink / raw)
To: Qingfang Deng, Thomas Gleixner, Palmer Dabbelt, Paul Walmsley,
Albert Ou, Atish Patra, linux-kernel, linux-riscv
Cc: Christoph Hellwig, Qingfang Deng
Hi Qingfang,
On 22/03/2024 18:08, Alexandre Ghiti wrote:
> Hi Qingfang,
>
> On 22/03/2024 10:00, Qingfang Deng wrote:
>> From: Qingfang Deng <qingfang.deng@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@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;
>
So this is actually already fixed in 6.9-rc1 by this commit:
956521064780 ("irqchip/sifive-plic: Parse number of interrupts and
contexts early in plic_probe()").
Thanks,
Alex
>
> You can add:
>
> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
>
> Thanks,
>
> Alex
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-25 20:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-22 9:00 [PATCH] irqchip/sifive-plic: Fix error handling of of_property_read_u32 Qingfang Deng
2024-03-22 17:08 ` Alexandre Ghiti
2024-03-25 20:45 ` Alexandre Ghiti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox