Skip to contentSkip to conversation

EDAC/mpc85xx: don't use devm for request_irq()

PATCH In review Rosen Penev 2 participants 3 messages Jul 31

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

PATCH 1/1 EDAC/mpc85xx: don't use devm for request_irq()

Use modern irq acquisition APIs to avoid having to call irq_dispose_mapping() since there's no real need to copy the mapping.

Use non devm version of request_irq() as IRQ need to be freed before edac_device_del_device() to avoid a use after free issue.

---
 drivers/edac/mpc85xx_edac.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/edac/mpc85xx_edac.c +18 -7
index a78d702674f6..651d14b01e25 100644
@@ -253,15 +253,19 @@ static int mpc85xx_pci_err_probe(struct platform_device *op)
 	}
 
 	if (edac_op_state == EDAC_OPSTATE_INT) {
-		pdata->irq = irq_of_parse_and_map(of_node, 0);
-		res = devm_request_irq(&op->dev, pdata->irq,
+		pdata->irq = of_irq_get(of_node, 0);
+		if (pdata->irq < 0) {
+			res = pdata->irq;
+			goto err2;
+		}
+
+		res = request_irq(pdata->irq,
 				       mpc85xx_pci_isr,
 				       IRQF_SHARED,
 				       "[EDAC] PCI err", pci);
 		if (res < 0) {
 			pr_err("%s: Unable to request irq %d for MPC85xx PCI err\n",
 				__func__, pdata->irq);
-			irq_dispose_mapping(pdata->irq);
 			res = -ENODEV;
 			goto err2;
 		}
@@ -304,6 +308,9 @@ static void mpc85xx_pci_err_remove(struct platform_device *op)
 
 	edac_dbg(0, "\n");
 
+	if (edac_op_state == EDAC_OPSTATE_INT)
+		free_irq(pdata->irq, edac_dev);
+
 	out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ADDR, orig_pci_err_cap_dr);
 	out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, orig_pci_err_en);
 
@@ -558,14 +565,18 @@ static int mpc85xx_l2_err_probe(struct platform_device *op)
 	}
 
 	if (edac_op_state == EDAC_OPSTATE_INT) {
-		pdata->irq = irq_of_parse_and_map(op->dev.of_node, 0);
-		res = devm_request_irq(&op->dev, pdata->irq,
+		pdata->irq = platform_get_irq(op, 0);
+		if (pdata->irq < 0) {
+			res = pdata->irq;
+			goto err2;
+		}
+
+		res = request_irq(pdata->irq,
 				       mpc85xx_l2_isr, IRQF_SHARED,
 				       "[EDAC] L2 err", edac_dev);
 		if (res < 0) {
 			pr_err("%s: Unable to request irq %d for MPC85xx L2 err\n",
 				__func__, pdata->irq);
-			irq_dispose_mapping(pdata->irq);
 			res = -ENODEV;
 			goto err2;
 		}
@@ -597,7 +608,7 @@ static void mpc85xx_l2_err_remove(struct platform_device *op)
 
 	if (edac_op_state == EDAC_OPSTATE_INT) {
 		out_be32(pdata->l2_vbase + MPC85XX_L2_ERRINTEN, 0);
-		irq_dispose_mapping(pdata->irq);
+		free_irq(pdata->irq, edac_dev);
 	}
 
 	out_be32(pdata->l2_vbase + MPC85XX_L2_ERRDIS, orig_l2_err_disable);
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 10 lines · Rosen Penev

Use modern irq acquisition APIs to avoid having to call irq_dispose_mapping() since there's no real need to copy the mapping.

Use non devm version of request_irq() as IRQ need to be freed before edac_device_del_device() to avoid a use after free issue.

---
 drivers/edac/mpc85xx_edac.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

You were on the thread where we orphaned that driver because we have no hw to test it on, right?

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#2 lore raw
Quoted 8 lines · Borislav Petkov
Quoted 6 lines · Rosen Penev

Use modern irq acquisition APIs to avoid having to call irq_dispose_mapping() since there's no real need to copy the mapping.

Use non devm version of request_irq() as IRQ need to be freed before edac_device_del_device() to avoid a use after free issue.

Quoted 7 lines
Quoted 4 lines
---
 drivers/edac/mpc85xx_edac.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

You were on the thread where we orphaned that driver because we have no hw to test it on, right?

yes.

For whatever reason, sashiko flagged this in a different driver

https://sashiko.dev/#/patchset/20260719194009.117532-1-rosenp%40gmail.com

Quoted 6 lines

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette