[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H6C9BdQ3uXaKpasLTPFQqNRuA8JTsCE6ONF07fshVJMYQ@mail.gmail.com>
Date: Wed, 10 Sep 2025 11:13:13 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Colin Ian King <colin.i.king@...il.com>
Cc: Yinbo Zhu <zhuyinbo@...ngson.cn>, Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>, Yao Zi <ziyao@...root.org>, linux-gpio@...r.kernel.org,
kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][next] gpio: loongson-64bit: Fix a less than zero check on
an unsigned int struct field
Hi, Colin,
On Wed, Sep 10, 2025 at 3:04 AM Colin Ian King <colin.i.king@...il.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@...il.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@...ngson.cn>
> "failed to get IRQ %d\n", i);
> + chip->irq.parents[i] = ret;
> }
>
> for (i = 0; i < data->intr_num; i++) {
> --
> 2.51.0
>
Powered by blists - more mailing lists