diff mbox series

gpio: ath79: Add missing check for platform_get_irq

Message ID 20230601085132.12508-1-jiasheng@iscas.ac.cn
State New
Headers show
Series gpio: ath79: Add missing check for platform_get_irq | expand

Commit Message

Jiasheng Jiang June 1, 2023, 8:51 a.m. UTC
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(+)

Comments

Andy Shevchenko June 2, 2023, 1:32 a.m. UTC | #1
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)?
diff mbox series

Patch

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;
 	}