diff mbox series

[2/5] edac: altera: add IRQ check for Arria10

Message ID 20220126200353.14582-3-s.shtylyov@omp.ru (mailing list archive)
State New, archived
Headers show
Series Stop calling request_irq(), etc. with invalid IRQs in the EDAC drivers | expand

Commit Message

Sergey Shtylyov Jan. 26, 2022, 8:03 p.m. UTC
The driver neglects to check the result of platform_get_irq()'s call
and blithely passes the negative error codes to devm_request_irq()
(which takes *unsigned* IRQ #), causing it to fail with -EINVAL,
overriding the original error.  Stop calling devm_request_irq()
with the invalid IRQ #s.

While at it, move the call to platform_get_irq() to the place where
it makes more sense...

Fixes: 73bcc942f427 ("EDAC, altera: Add Arria10 EDAC support")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/edac/altera_edac.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 3b6a2650cf5b..21b5d2fac9be 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -353,9 +353,6 @@  static int altr_sdram_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	/* Arria10 has a 2nd IRQ */
-	irq2 = platform_get_irq(pdev, 1);
-
 	layers[0].type = EDAC_MC_LAYER_CHIP_SELECT;
 	layers[0].size = 1;
 	layers[0].is_virt_csrow = true;
@@ -406,6 +403,12 @@  static int altr_sdram_probe(struct platform_device *pdev)
 		if (res < 0)
 			goto err2;
 
+		/* Arria10 has a 2nd IRQ */
+		irq2 = platform_get_irq(pdev, 1);
+		if (irq2 < 0) {
+			res = irq2;
+			goto err2;
+		}
 		res = devm_request_irq(&pdev->dev, irq2,
 				       altr_sdram_mc_err_handler,
 				       IRQF_SHARED, dev_name(&pdev->dev), mci);