public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: sifive: Add missing check for platform_get_irq
@ 2023-06-01  8:24 Jiasheng Jiang
  2023-06-02  1:34 ` andy.shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2023-06-01  8:24 UTC (permalink / raw)
  To: linus.walleij, brgl, palmer, paul.walmsley
  Cc: linux-gpio, linux-riscv, linux-kernel, Jiasheng Jiang

Add missing check for platform_get_irq and return error
if it fails.

Fixes: f52d6d8b43e5 ("gpio: sifive: To get gpio irq offset from device tree data")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/gpio/gpio-sifive.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
index 98939cd4a71e..7bca9c415564 100644
--- a/drivers/gpio/gpio-sifive.c
+++ b/drivers/gpio/gpio-sifive.c
@@ -221,8 +221,11 @@ static int sifive_gpio_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	for (i = 0; i < ngpio; i++)
+	for (i = 0; i < ngpio; i++) {
 		chip->irq_number[i] = platform_get_irq(pdev, i);
+		if (chip->irq_number[i] < 0)
+			return -ENODEV;
+	}
 
 	ret = bgpio_init(&chip->gc, dev, 4,
 			 chip->base + SIFIVE_GPIO_INPUT_VAL,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: sifive: Add missing check for platform_get_irq
  2023-06-01  8:24 [PATCH] gpio: sifive: Add missing check for platform_get_irq Jiasheng Jiang
@ 2023-06-02  1:34 ` andy.shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: andy.shevchenko @ 2023-06-02  1:34 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: linus.walleij, brgl, palmer, paul.walmsley, linux-gpio,
	linux-riscv, linux-kernel

Thu, Jun 01, 2023 at 04:24:40PM +0800, Jiasheng Jiang kirjoitti:
> Add missing check for platform_get_irq and return error

Also refer to the functions as func(), like platform_get_irq().

> if it fails.

...

> +	for (i = 0; i < ngpio; i++) {
>  		chip->irq_number[i] = platform_get_irq(pdev, i);
> +		if (chip->irq_number[i] < 0)
> +			return -ENODEV;

Same as per the other email, why has the error code to be shadow?

> +	}

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-02  1:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01  8:24 [PATCH] gpio: sifive: Add missing check for platform_get_irq Jiasheng Jiang
2023-06-02  1:34 ` andy.shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox