linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: ath79: Add missing check for platform_get_irq
@ 2023-06-01  8:51 Jiasheng Jiang
  2023-06-02  1:32 ` andy.shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Jiasheng Jiang @ 2023-06-01  8:51 UTC (permalink / raw)
  To: albeu, linus.walleij, brgl; +Cc: linux-gpio, linux-kernel, Jiasheng Jiang

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

Fixes: 2b8f89e19b6d ("gpio: ath79: Add support for the interrupt controller")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/gpio/gpio-ath79.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c
index aa0a954b8392..4b67428a8c17 100644
--- a/drivers/gpio/gpio-ath79.c
+++ b/drivers/gpio/gpio-ath79.c
@@ -286,6 +286,8 @@ static int ath79_gpio_probe(struct platform_device *pdev)
 		if (!girq->parents)
 			return -ENOMEM;
 		girq->parents[0] = platform_get_irq(pdev, 0);
+		if (girq->parents[0] < 0)
+			return -ENODEV;
 		girq->default_type = IRQ_TYPE_NONE;
 		girq->handler = handle_simple_irq;
 	}
-- 
2.25.1


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

* Re: [PATCH] gpio: ath79: Add missing check for platform_get_irq
  2023-06-01  8:51 [PATCH] gpio: ath79: Add missing check for platform_get_irq Jiasheng Jiang
@ 2023-06-02  1:32 ` andy.shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: andy.shevchenko @ 2023-06-02  1:32 UTC (permalink / raw)
  To: Jiasheng Jiang; +Cc: albeu, linus.walleij, brgl, linux-gpio, linux-kernel

Thu, Jun 01, 2023 at 04:51:32PM +0800, Jiasheng Jiang kirjoitti:
> Add the missing check for platform_get_irq and return error
> if it fails.

>  		girq->parents[0] = platform_get_irq(pdev, 0);
> +		if (girq->parents[0] < 0)
> +			return -ENODEV;

Can you elaborate why error code has to be shadowed (overriden)?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] gpio: ath79: Add missing check for platform_get_irq
@ 2023-06-02  3:15 Jiasheng Jiang
  0 siblings, 0 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2023-06-02  3:15 UTC (permalink / raw)
  To: andy.shevchenko
  Cc: albeu, linus.walleij, brgl, linux-gpio, linux-kernel,
	Jiasheng Jiang

Thu, Jun 02, 2023 at 09:32:00 +0800, Andy Shevchenko wrote:
> Thu, Jun 01, 2023 at 04:51:32PM +0800, Jiasheng Jiang kirjoitti:
>> Add the missing check for platform_get_irq and return error
>> if it fails.
> 
>>  		girq->parents[0] = platform_get_irq(pdev, 0);
>> +		if (girq->parents[0] < 0)
>> +			return -ENODEV;
> 
> Can you elaborate why error code has to be shadowed (overriden)?

You are right.
Returning the error code is better.
I will submit a v2.
The same goes for the other patch
"gpio: sifive: Add missing check for platform_get_irq".

Thanks,
Jiasheng


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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01  8:51 [PATCH] gpio: ath79: Add missing check for platform_get_irq Jiasheng Jiang
2023-06-02  1:32 ` andy.shevchenko
  -- strict thread matches above, loose matches on Subject: below --
2023-06-02  3:15 Jiasheng Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).