diff mbox series

irqchip/sifive-plic: Fix error handling of of_property_read_u32

Message ID 20240322090002.311645-1-dqfext@gmail.com (mailing list archive)
State Superseded
Headers show
Series irqchip/sifive-plic: Fix error handling of of_property_read_u32 | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh
conchuod/patch-1-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh
conchuod/patch-1-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh
conchuod/patch-1-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-1-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-1-test-6 success .github/scripts/patches/tests/checkpatch.sh
conchuod/patch-1-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh
conchuod/patch-1-test-8 success .github/scripts/patches/tests/header_inline.sh
conchuod/patch-1-test-9 success .github/scripts/patches/tests/kdoc.sh
conchuod/patch-1-test-10 success .github/scripts/patches/tests/module_param.sh
conchuod/patch-1-test-11 success .github/scripts/patches/tests/verify_fixes.sh
conchuod/patch-1-test-12 success .github/scripts/patches/tests/verify_signedoff.sh
conchuod/vmtest-fixes-PR fail merge-conflict

Commit Message

Qingfang Deng March 22, 2024, 9 a.m. UTC
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(-)

Comments

Alexandre Ghiti March 22, 2024, 5:08 p.m. UTC | #1
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
Alexandre Ghiti March 25, 2024, 8:45 p.m. UTC | #2
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
diff mbox series

Patch

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;