From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Alexandre Belloni <alexandre.belloni@bootlin.com>,
Domen Puncer <domen.puncer@telargo.com>,
John Rigby <jcrigby@gmail.com>,
linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 04/10] rtc: mpc5121: get interrupts via platform_get_irq()
Date: Mon, 23 Nov 2026 19:59:15 +0000 [thread overview]
Message-ID: <20261123200012.502284-5-lee@kernel.org> (raw)
In-Reply-To: <20261123200012.502284-1-lee@kernel.org>
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@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
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(®s->alm_enable, 0);
out_8(®s->int_enable, in_8(®s->int_enable) & ~0x1);
-
- irq_dispose_mapping(rtc->irq);
- irq_dispose_mapping(rtc->irq_periodic);
}
#ifdef CONFIG_OF
--
2.56.1.750.gf70dc682cf-goog
next prev parent reply other threads:[~2026-11-23 20:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 19:59 [PATCH 00/10] rtc: assorted bug fixes across RTC drivers Lee Jones
2026-11-23 19:59 ` [PATCH 01/10] rtc: rx8025: pass parent I2C device in clock_adjust_ppb sysfs callbacks Lee Jones
2026-11-23 19:59 ` [PATCH 02/10] rtc: mt6397: handle non-DT platform device matching in probe Lee Jones
2026-11-23 19:59 ` [PATCH 03/10] rtc: ma35d1: allocate RTC device before requesting interrupt Lee Jones
2026-11-23 19:59 ` Lee Jones [this message]
2026-11-23 19:59 ` [PATCH 05/10] rtc: m41t80: use devm helpers for square-wave clock registration Lee Jones
2026-11-23 19:59 ` [PATCH 06/10] rtc: nct3018y: fix clock provider use-after-free and leak on unbind Lee Jones
2026-11-23 19:59 ` [PATCH 07/10] rtc: stmp3xxx: unregister child watchdog platform device " Lee Jones
2026-11-23 19:59 ` [PATCH 08/10] rtc: ds1685: check driver data for NULL in ds1685_rtc_poweroff() Lee Jones
2026-11-23 19:59 ` [PATCH 09/10] rtc: omap: prevent NULL and dangling pointer dereferences in power-off path Lee Jones
2026-11-23 19:59 ` [PATCH 10/10] rtc: bq32k: use u8 register buffer in trickle_charge_bypass sysfs Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123200012.502284-5-lee@kernel.org \
--to=lee@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=domen.puncer@telargo.com \
--cc=jcrigby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®