* [PATCH][next] gpio: loongson-64bit: Fix a less than zero check on an unsigned int struct field
@ 2025-09-09 19:03 Colin Ian King
2025-09-10 3:09 ` Yao Zi
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Colin Ian King @ 2025-09-09 19:03 UTC (permalink / raw)
To: Yinbo Zhu, Linus Walleij, Bartosz Golaszewski, Yao Zi,
Huacai Chen, linux-gpio
Cc: kernel-janitors, linux-kernel
Currently the error check from the call to platform_get_irq is always
false because an unsigned int chip->irq.parents[i] is being used to
to perform the less than zero error check. Fix this by using the int
variable ret to perform the check.
Fixes: 03c146cb6cd1 ("gpio: loongson-64bit: Add support for Loongson-2K0300 SoC")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
drivers/gpio/gpio-loongson-64bit.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-loongson-64bit.c b/drivers/gpio/gpio-loongson-64bit.c
index f84f8c537249..24b7219db34a 100644
--- a/drivers/gpio/gpio-loongson-64bit.c
+++ b/drivers/gpio/gpio-loongson-64bit.c
@@ -267,10 +267,13 @@ static int loongson_gpio_init_irqchip(struct platform_device *pdev,
return -ENOMEM;
for (i = 0; i < data->intr_num; i++) {
- chip->irq.parents[i] = platform_get_irq(pdev, i);
- if (chip->irq.parents[i] < 0)
- return dev_err_probe(&pdev->dev, chip->irq.parents[i],
+ int ret;
+
+ ret = platform_get_irq(pdev, i);
+ if (ret < 0)
+ return dev_err_probe(&pdev->dev, ret,
"failed to get IRQ %d\n", i);
+ chip->irq.parents[i] = ret;
}
for (i = 0; i < data->intr_num; i++) {
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH][next] gpio: loongson-64bit: Fix a less than zero check on an unsigned int struct field
2025-09-09 19:03 [PATCH][next] gpio: loongson-64bit: Fix a less than zero check on an unsigned int struct field Colin Ian King
@ 2025-09-10 3:09 ` Yao Zi
2025-09-10 3:13 ` Huacai Chen
2025-09-10 8:15 ` Bartosz Golaszewski
2 siblings, 0 replies; 4+ messages in thread
From: Yao Zi @ 2025-09-10 3:09 UTC (permalink / raw)
To: Colin Ian King, Yinbo Zhu, Linus Walleij, Bartosz Golaszewski,
Huacai Chen, linux-gpio
Cc: kernel-janitors, linux-kernel
On Tue, Sep 09, 2025 at 08:03:56PM +0100, Colin Ian King wrote:
> Currently the error check from the call to platform_get_irq is always
> false because an unsigned int chip->irq.parents[i] is being used to
> to perform the less than zero error check. Fix this by using the int
> variable ret to perform the check.
>
> Fixes: 03c146cb6cd1 ("gpio: loongson-64bit: Add support for Loongson-2K0300 SoC")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> drivers/gpio/gpio-loongson-64bit.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
Thanks for catching this,
Reviewed-by: Yao Zi <ziyao@disroot.org>
> diff --git a/drivers/gpio/gpio-loongson-64bit.c b/drivers/gpio/gpio-loongson-64bit.c
> index f84f8c537249..24b7219db34a 100644
> --- a/drivers/gpio/gpio-loongson-64bit.c
> +++ b/drivers/gpio/gpio-loongson-64bit.c
> @@ -267,10 +267,13 @@ static int loongson_gpio_init_irqchip(struct platform_device *pdev,
> return -ENOMEM;
>
> for (i = 0; i < data->intr_num; i++) {
> - chip->irq.parents[i] = platform_get_irq(pdev, i);
> - if (chip->irq.parents[i] < 0)
> - return dev_err_probe(&pdev->dev, chip->irq.parents[i],
> + int ret;
> +
> + ret = platform_get_irq(pdev, i);
> + if (ret < 0)
> + return dev_err_probe(&pdev->dev, ret,
> "failed to get IRQ %d\n", i);
> + chip->irq.parents[i] = ret;
> }
>
> for (i = 0; i < data->intr_num; i++) {
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH][next] gpio: loongson-64bit: Fix a less than zero check on an unsigned int struct field
2025-09-09 19:03 [PATCH][next] gpio: loongson-64bit: Fix a less than zero check on an unsigned int struct field Colin Ian King
2025-09-10 3:09 ` Yao Zi
@ 2025-09-10 3:13 ` Huacai Chen
2025-09-10 8:15 ` Bartosz Golaszewski
2 siblings, 0 replies; 4+ messages in thread
From: Huacai Chen @ 2025-09-10 3:13 UTC (permalink / raw)
To: Colin Ian King
Cc: Yinbo Zhu, Linus Walleij, Bartosz Golaszewski, Yao Zi,
linux-gpio, kernel-janitors, linux-kernel
Hi, Colin,
On Wed, Sep 10, 2025 at 3:04 AM Colin Ian King <colin.i.king@gmail.com> wrote:
>
> Currently the error check from the call to platform_get_irq is always
> false because an unsigned int chip->irq.parents[i] is being used to
> to perform the less than zero error check. Fix this by using the int
> variable ret to perform the check.
>
> Fixes: 03c146cb6cd1 ("gpio: loongson-64bit: Add support for Loongson-2K0300 SoC")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> drivers/gpio/gpio-loongson-64bit.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-loongson-64bit.c b/drivers/gpio/gpio-loongson-64bit.c
> index f84f8c537249..24b7219db34a 100644
> --- a/drivers/gpio/gpio-loongson-64bit.c
> +++ b/drivers/gpio/gpio-loongson-64bit.c
> @@ -267,10 +267,13 @@ static int loongson_gpio_init_irqchip(struct platform_device *pdev,
> return -ENOMEM;
>
> for (i = 0; i < data->intr_num; i++) {
> - chip->irq.parents[i] = platform_get_irq(pdev, i);
> - if (chip->irq.parents[i] < 0)
> - return dev_err_probe(&pdev->dev, chip->irq.parents[i],
> + int ret;
> +
> + ret = platform_get_irq(pdev, i);
> + if (ret < 0)
> + return dev_err_probe(&pdev->dev, ret,
Then this line becomes short enough, and the "return ..." can be in one line.
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> "failed to get IRQ %d\n", i);
> + chip->irq.parents[i] = ret;
> }
>
> for (i = 0; i < data->intr_num; i++) {
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH][next] gpio: loongson-64bit: Fix a less than zero check on an unsigned int struct field
2025-09-09 19:03 [PATCH][next] gpio: loongson-64bit: Fix a less than zero check on an unsigned int struct field Colin Ian King
2025-09-10 3:09 ` Yao Zi
2025-09-10 3:13 ` Huacai Chen
@ 2025-09-10 8:15 ` Bartosz Golaszewski
2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2025-09-10 8:15 UTC (permalink / raw)
To: Yinbo Zhu, Linus Walleij, Bartosz Golaszewski, Yao Zi,
Huacai Chen, linux-gpio, Colin Ian King
Cc: Bartosz Golaszewski, kernel-janitors, linux-kernel
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Tue, 09 Sep 2025 20:03:56 +0100, Colin Ian King wrote:
> Currently the error check from the call to platform_get_irq is always
> false because an unsigned int chip->irq.parents[i] is being used to
> to perform the less than zero error check. Fix this by using the int
> variable ret to perform the check.
>
>
Applied, thanks!
[1/1] gpio: loongson-64bit: Fix a less than zero check on an unsigned int struct field
https://git.kernel.org/brgl/linux/c/4c91b0ee35db07ae017dce067c64364c7e95faae
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-10 8:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-09 19:03 [PATCH][next] gpio: loongson-64bit: Fix a less than zero check on an unsigned int struct field Colin Ian King
2025-09-10 3:09 ` Yao Zi
2025-09-10 3:13 ` Huacai Chen
2025-09-10 8:15 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®