Skip to contentSkip to conversation

Stop calling request_irq(), etc. with invalid IRQs in the EDAC drivers

PATCH New Sergey Shtylyov 1 participant 6 messages Jan 26, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Stop calling request_irq(), etc. with invalid IRQs in the EDAC drivers

Here are 5 patches against the 'edac-for-next' branch of the 'ras.git' repo (for the lack of a better branch for fixes?). The affected drivers call platform_get_irq() but largely ignore its result -- they blithely pass the negative error codes to request_irq() (and its ilk) which expects *unsigned* IRQ #. Stop doing that by checking what exactly platform_get_irq() returns.

Sergey Shtylyov (5):
edac: altera: add IRQ checks for L2 cache and OCRAM
edac: altera: add IRQ check for Arria10
edac: fsl_ddr: add IRQ check
edac: highbank_l2: add IRQ checks
edac: highbank_mc: add IRQ check

 drivers/edac/altera_edac.c      | 17 ++++++++++++++---
 drivers/edac/fsl_ddr_edac.c     |  4 ++++
 drivers/edac/highbank_l2_edac.c |  8 ++++++++
 drivers/edac/highbank_mc_edac.c |  4 ++++
 4 files changed, 30 insertions(+), 3 deletions(-)
Signature · 1 line
2.26.3
#1 lore raw

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

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")
---
 drivers/edac/altera_edac.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/edac/altera_edac.c +8 -0
index 3a6d2416cb0f..3b6a2650cf5b 100644
@@ -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);
Signature · 1 line
2.26.3
#2 lore raw

PATCH 2/5 edac: altera: add IRQ check for Arria10

In reply to Sergey Shtylyov

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")
---
 drivers/edac/altera_edac.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/edac/altera_edac.c +6 -3
index 3b6a2650cf5b..21b5d2fac9be 100644
@@ -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);
Signature · 1 line
2.26.3
#3 lore raw

PATCH 3/5 edac: fsl_ddr: add IRQ check

In reply to Sergey Shtylyov

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.

Fixes 55764ed37eec ("EDAC, fsl_ddr: Fix IRQ dispose warning when module is removed")
---
 drivers/edac/fsl_ddr_edac.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/edac/fsl_ddr_edac.c +4 -0
index 6d8ea226010d..64f1108726b0 100644
@@ -586,6 +586,10 @@ int fsl_mc_err_probe(struct platform_device *op)
 
 		/* register interrupts */
 		pdata->irq = platform_get_irq(op, 0);
+		if (pdata->irq < 0) {
+			res = pdata->irq;
+			goto err2;
+		}
 		res = devm_request_irq(&op->dev, pdata->irq,
 				       fsl_mc_isr,
 				       IRQF_SHARED,
Signature · 1 line
2.26.3
#4 lore raw

PATCH 4/5 edac: highbank_l2: add IRQ checks

In reply to Sergey Shtylyov

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 69154d069869 ("edac: add support for Calxeda highbank L2 cache ecc")
---
 drivers/edac/highbank_l2_edac.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/edac/highbank_l2_edac.c +8 -0
index c4549cec788b..e58c84f8e624 100644
@@ -94,6 +94,10 @@ static int highbank_l2_err_probe(struct platform_device *pdev)
 		goto err;
 
 	drvdata->db_irq = platform_get_irq(pdev, 0);
+	if (drvdata->db_irq < 0) {
+		res = drvdata->db_irq;
+		goto err2;
+	}
 	res = devm_request_irq(&pdev->dev, drvdata->db_irq,
 			       highbank_l2_err_handler,
 			       0, dev_name(&pdev->dev), dci);
@@ -101,6 +105,10 @@ static int highbank_l2_err_probe(struct platform_device *pdev)
 		goto err2;
 
 	drvdata->sb_irq = platform_get_irq(pdev, 1);
+	if (drvdata->sb_irq < 0) {
+		res = drvdata->sb_irq;
+		goto err2;
+	}
 	res = devm_request_irq(&pdev->dev, drvdata->sb_irq,
 			       highbank_l2_err_handler,
 			       0, dev_name(&pdev->dev), dci);
Signature · 1 line
2.26.3
#5 lore raw

PATCH 5/5 edac: highbank_mc: add IRQ check

In reply to Sergey Shtylyov

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.

Fixes a1b01edb2745 ("edac: add support for Calxeda highbank memory controller")
---
 drivers/edac/highbank_mc_edac.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/edac/highbank_mc_edac.c +4 -0
index 61b76ec226af..36931cafcab0 100644
@@ -230,6 +230,10 @@ static int highbank_mc_probe(struct platform_device *pdev)
 		goto err;
 
 	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		res = irq;
+		goto err;
+	}
 	res = devm_request_irq(&pdev->dev, irq, highbank_mc_err_handler,
 			       0, dev_name(&pdev->dev), mci);
 	if (res < 0) {
Signature · 1 line
2.26.3