diff mbox series

[v3] gpio: ath79: Add missing check for platform_get_irq

Message ID 20230606031841.38665-1-jiasheng@iscas.ac.cn (mailing list archive)
State Handled Elsewhere
Headers show
Series [v3] gpio: ath79: Add missing check for platform_get_irq | expand

Checks

Context Check Description
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be fixes at HEAD 6966d7988c4f
conchuod/fixes_present success Fixes tag present in non-next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 6 and now 6
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 8 this patch: 8
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 8 this patch: 8
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 3 this patch: 3
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success Fixes tag looks correct
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Jiasheng Jiang June 6, 2023, 3:18 a.m. UTC
Add the missing check for platform_get_irq() and return error
if it fails.
The returned error code will be dealed with in
module_platform_driver(ath79_gpio_driver) and the driver will not
be registered.

Fixes: 2b8f89e19b6d ("gpio: ath79: Add support for the interrupt controller")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
Changelog:

v2 -> v3:

1. Check before assigning values.

v1 -> v2:

1. Return "girq->parents[0]" instead of "-ENODEV".
---
 drivers/gpio/gpio-ath79.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Andy Shevchenko June 6, 2023, 9:28 a.m. UTC | #1
Tue, Jun 06, 2023 at 11:18:41AM +0800, Jiasheng Jiang kirjoitti:

Is this v4?

> Add the missing check for platform_get_irq() and return error
> if it fails.
> The returned error code will be dealed with in
> module_platform_driver(ath79_gpio_driver) and the driver will not
> be registered.

No, this functional change and has not to be for the fixes unless _this_ is the
regression you are fixing. Did the driver work before at some point as after
this change?

Otherwise you have to _justify_ that this functional change won't break
existing setups (with broked IRQ in Device Tree, for example).
Andy Shevchenko June 6, 2023, 9:46 a.m. UTC | #2
Tue, Jun 06, 2023 at 12:28:17PM +0300, andy.shevchenko@gmail.com kirjoitti:
> Tue, Jun 06, 2023 at 11:18:41AM +0800, Jiasheng Jiang kirjoitti:
> 
> Is this v4?
> 
> > Add the missing check for platform_get_irq() and return error
> > if it fails.
> > The returned error code will be dealed with in
> > module_platform_driver(ath79_gpio_driver) and the driver will not
> > be registered.
> 
> No, this functional change and has not to be for the fixes unless _this_ is the
> regression you are fixing. Did the driver work before at some point as after
> this change?

To be more clear, answer to the following questions:
1) does driver work with wrong DT configuration?
2a) if yes, does it make sense, i.e. the hardware functioning usefully?
2b) if yes, can we guarantee there are no broken configurations in the wild?

Depending on the answers correct your code and/or commit message.

> Otherwise you have to _justify_ that this functional change won't break
> existing setups (with broked IRQ in Device Tree, for example).
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c
index aa0a954b8392..d2d838ad33bb 100644
--- a/drivers/gpio/gpio-ath79.c
+++ b/drivers/gpio/gpio-ath79.c
@@ -285,7 +285,10 @@  static int ath79_gpio_probe(struct platform_device *pdev)
 					     GFP_KERNEL);
 		if (!girq->parents)
 			return -ENOMEM;
-		girq->parents[0] = platform_get_irq(pdev, 0);
+		err = platform_get_irq(pdev, 0);
+		if (err < 0)
+			return err;
+		girq->parents[0] = err;
 		girq->default_type = IRQ_TYPE_NONE;
 		girq->handler = handle_simple_irq;
 	}