[PATCH v5 2/9] EDAC/aspeed: Free the interrupt before the mem_ctl_info on remove
Ryan Chen
ryan_chen at aspeedtech.com
Tue Oct 6 23:13:19 PDT 2026
The ECC interrupt is devm-managed, so it is only released after .remove()
has returned, and masking the controller does not wait for a handler
already running on another CPU. edac_mc_free() can therefore free the
mem_ctl_info the handler uses as its context while it is still running.
Register the handler with request_irq() and free it before the memory
it uses. aspeed_probe() returns as soon as config_irq() succeeds, so
devres has no error path left to unwind.
Fixes: 9b7e6242ee4e ("EDAC, aspeed: Add an Aspeed AST2500 EDAC driver")
Signed-off-by: Ryan Chen <ryan_chen at aspeedtech.com>
---
Changes in v5:
- Use request_irq()/free_irq() rather than devm_request_irq() followed
by an explicit free, and keep the interrupt number in a file-scope
variable so aspeed_remove() does not have to call platform_get_irq()
a second time.
Changes in v4:
- Drop the Cc: stable tag.
Changes in v2:
- New patch.
---
drivers/edac/aspeed_edac.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c
index 83d60414f89a..cb233a33d29a 100644
--- a/drivers/edac/aspeed_edac.c
+++ b/drivers/edac/aspeed_edac.c
@@ -36,6 +36,7 @@
static struct regmap *aspeed_regmap;
+static int aspeed_irq;
static int regmap_reg_write(void *context, unsigned int reg, unsigned int val)
@@ -212,11 +213,12 @@ static int config_irq(void *ctx, struct platform_device *pdev)
if (irq < 0)
return irq;
- rc = devm_request_irq(&pdev->dev, irq, mcr_isr, IRQF_TRIGGER_HIGH,
- DRV_NAME, ctx);
+ rc = request_irq(irq, mcr_isr, IRQF_TRIGGER_HIGH, DRV_NAME, ctx);
if (rc)
return rc;
+ aspeed_irq = irq;
+
/* enable interrupts */
regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL,
ASPEED_MCR_INTR_CTRL_ENABLE,
@@ -364,6 +366,8 @@ static void aspeed_remove(struct platform_device *pdev)
regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL,
ASPEED_MCR_INTR_CTRL_ENABLE, 0);
+ free_irq(aspeed_irq, platform_get_drvdata(pdev));
+
/* free resources */
mci = edac_mc_del_mc(&pdev->dev);
if (mci)
--
2.34.1
More information about the linux-arm-kernel
mailing list