[PATCH 04/10] rtc: mpc5121: get interrupts via platform_get_irq()

From: Lee Jones

Date: Mon Nov 23 2026 - 15:00:56 EST


mpc5121_rtc_probe() maps its interrupts with irq_of_parse_and_map() and
requests them via devm_request_irq(), while the probe error paths and
mpc5121_rtc_remove() explicitly call irq_dispose_mapping(). This tears
down and frees the IRQ descriptors before devres runs free_irq(),
operating on destroyed IRQ descriptors and leaking irqaction entries.
It also passes IRQ 0 to devm_request_irq() when irq_of_parse_and_map()
fails.

Obtain both interrupts via platform_get_irq(), propagate negative error
codes directly, and drop the manual irq_dispose_mapping() calls.

Fixes: d53d4ae981d0 ("rtc: mpc5121: simplify probe")
Closes: https://sashiko.dev/#/bug/linux-3fc27b53-f5d6-493d-a3c3-2af748b44f7e
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/rtc/rtc-mpc5121.c | 41 ++++++++++++++-------------------------
1 file changed, 15 insertions(+), 26 deletions(-)

diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c
index e1cef77c1a0e..331851378e8a 100644
--- a/drivers/rtc/rtc-mpc5121.c
+++ b/drivers/rtc/rtc-mpc5121.c
@@ -11,7 +11,6 @@
#include <linux/module.h>
#include <linux/rtc.h>
#include <linux/of.h>
-#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/slab.h>
@@ -72,8 +71,8 @@ struct mpc5121_rtc_regs {
};

struct mpc5121_rtc_data {
- unsigned irq;
- unsigned irq_periodic;
+ int irq;
+ int irq_periodic;
struct mpc5121_rtc_regs __iomem *regs;
struct rtc_device *rtc;
struct rtc_wkalrm wkalarm;
@@ -307,30 +306,34 @@ static int mpc5121_rtc_probe(struct platform_device *op)

platform_set_drvdata(op, rtc);

- rtc->irq = irq_of_parse_and_map(op->dev.of_node, 1);
+ rtc->irq = platform_get_irq(op, 1);
+ if (rtc->irq < 0)
+ return rtc->irq;
+
err = devm_request_irq(&op->dev, rtc->irq, mpc5121_rtc_handler, 0,
"mpc5121-rtc", &op->dev);
if (err) {
dev_err(&op->dev, "%s: could not request irq: %i\n",
__func__, rtc->irq);
- goto out_dispose;
+ return err;
}

- rtc->irq_periodic = irq_of_parse_and_map(op->dev.of_node, 0);
+ rtc->irq_periodic = platform_get_irq(op, 0);
+ if (rtc->irq_periodic < 0)
+ return rtc->irq_periodic;
+
err = devm_request_irq(&op->dev, rtc->irq_periodic,
mpc5121_rtc_handler_upd, 0, "mpc5121-rtc_upd",
&op->dev);
if (err) {
dev_err(&op->dev, "%s: could not request irq: %i\n",
__func__, rtc->irq_periodic);
- goto out_dispose2;
+ return err;
}

rtc->rtc = devm_rtc_allocate_device(&op->dev);
- if (IS_ERR(rtc->rtc)) {
- err = PTR_ERR(rtc->rtc);
- goto out_dispose2;
- }
+ if (IS_ERR(rtc->rtc))
+ return PTR_ERR(rtc->rtc);

rtc->rtc->ops = &mpc5200_rtc_ops;
set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->rtc->features);
@@ -356,18 +359,7 @@ static int mpc5121_rtc_probe(struct platform_device *op)
rtc->rtc->range_max = U32_MAX;
}

- err = devm_rtc_register_device(rtc->rtc);
- if (err)
- goto out_dispose2;
-
- return 0;
-
-out_dispose2:
- irq_dispose_mapping(rtc->irq_periodic);
-out_dispose:
- irq_dispose_mapping(rtc->irq);
-
- return err;
+ return devm_rtc_register_device(rtc->rtc);
}

static void mpc5121_rtc_remove(struct platform_device *op)
@@ -378,9 +370,6 @@ static void mpc5121_rtc_remove(struct platform_device *op)
/* disable interrupt, so there are no nasty surprises */
out_8(&regs->alm_enable, 0);
out_8(&regs->int_enable, in_8(&regs->int_enable) & ~0x1);
-
- irq_dispose_mapping(rtc->irq);
- irq_dispose_mapping(rtc->irq_periodic);
}

#ifdef CONFIG_OF
--
2.56.1.750.gf70dc682cf-goog