diff mbox series

[1/5] edac: altera: add IRQ checks for L2 cache and OCRAM

Message ID 20220126200353.14582-2-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 calls
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.

Fixes: c3eea1942a16 ("EDAC, altera: Add Altera L2 cache and OCRAM support")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/edac/altera_edac.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 3a6d2416cb0f..3b6a2650cf5b 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -776,6 +776,10 @@  static int altr_edac_device_probe(struct platform_device *pdev)
 	}
 
 	drvdata->sb_irq = platform_get_irq(pdev, 0);
+	if (drvdata->sb_irq < 0) {
+		res = drvdata->sb_irq;
+		goto fail1;
+	}
 	res = devm_request_irq(&pdev->dev, drvdata->sb_irq,
 			       altr_edac_device_handler,
 			       0, dev_name(&pdev->dev), dci);
@@ -783,6 +787,10 @@  static int altr_edac_device_probe(struct platform_device *pdev)
 		goto fail1;
 
 	drvdata->db_irq = platform_get_irq(pdev, 1);
+	if (drvdata->db_irq < 0) {
+		res = drvdata->db_irq;
+		goto fail1;
+	}
 	res = devm_request_irq(&pdev->dev, drvdata->db_irq,
 			       altr_edac_device_handler,
 			       0, dev_name(&pdev->dev), dci);