From: Lee Jones <lee@kernel.org>
To: lee@kernel.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Chen-Yu Tsai <wens@kernel.org>,
Jassi Brar <jassisinghbrar@gmail.com>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev,
Philipp Zabel <p.zabel@pengutronix.de>,
Samuel Holland <samuel@sholland.org>
Subject: [PATCH 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown
Date: Thu, 3 Dec 2026 08:28:07 +0000 [thread overview]
Message-ID: <e17ca9554022bed48cc3b0878e7825ccaf7ba6a6.1796286447.git.lee@kernel.org> (raw)
In-Reply-To: <cover.1796286447.git.lee@kernel.org>
sun6i_msgbox_probe() requests the interrupt using devm_request_irq()
before initialising mbox->controller and mbox->lock, while
sun6i_msgbox_remove() manually calls mbox_controller_unregister() and
clk_disable_unprepare() before devres frees the IRQ. An interrupt
arriving during probe failure or device removal can access unclocked
MMIO registers or freed controller data in sun6i_msgbox_irq().
Retrieve the IRQ via platform_get_irq() and register it with
request_irq() after initialising mbox->controller and mbox->lock, then
explicitly call free_irq() before disabling the clock in both the probe
error path and sun6i_msgbox_remove().
Fixes: 25831c44b0b7 ("mailbox: sun6i-msgbox: Add a new mailbox driver")
Closes: https://sashiko.dev/#/bug/linux-b10c9846-995f-40c3-a18c-97b9cb0d0611
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
Cc: Chen-Yu Tsai <wens@kernel.org>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-sunxi@lists.linux.dev
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Samuel Holland <samuel@sholland.org>
drivers/mailbox/sun6i-msgbox.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/mailbox/sun6i-msgbox.c b/drivers/mailbox/sun6i-msgbox.c
index 1cbc4d478beb..4c5669035420 100644
--- a/drivers/mailbox/sun6i-msgbox.c
+++ b/drivers/mailbox/sun6i-msgbox.c
@@ -12,7 +12,6 @@
#include <linux/mailbox_controller.h>
#include <linux/module.h>
#include <linux/of.h>
-#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <linux/spinlock.h>
@@ -48,6 +47,7 @@ struct sun6i_msgbox {
struct clk *clk;
spinlock_t lock;
void __iomem *regs;
+ int irq;
};
static bool sun6i_msgbox_last_tx_done(struct mbox_chan *chan);
@@ -255,11 +255,6 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
/* Disable all IRQs for this end of the msgbox. */
writel(0, mbox->regs + LOCAL_IRQ_EN_REG);
- ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
- sun6i_msgbox_irq, 0, dev_name(dev), mbox);
- if (ret)
- goto err_disable_unprepare;
-
mbox->controller.dev = dev;
mbox->controller.ops = &sun6i_msgbox_chan_ops;
mbox->controller.chans = chans;
@@ -271,14 +266,26 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
spin_lock_init(&mbox->lock);
platform_set_drvdata(pdev, mbox);
+ mbox->irq = platform_get_irq(pdev, 0);
+ if (mbox->irq < 0) {
+ ret = mbox->irq;
+ goto err_disable_unprepare;
+ }
+
+ ret = request_irq(mbox->irq, sun6i_msgbox_irq, 0, dev_name(dev), mbox);
+ if (ret)
+ goto err_disable_unprepare;
+
ret = mbox_controller_register(&mbox->controller);
if (ret) {
dev_err(dev, "Failed to register controller: %d\n", ret);
- goto err_disable_unprepare;
+ goto err_free_irq;
}
return 0;
+err_free_irq:
+ free_irq(mbox->irq, mbox);
err_disable_unprepare:
clk_disable_unprepare(mbox->clk);
@@ -290,6 +297,7 @@ static void sun6i_msgbox_remove(struct platform_device *pdev)
struct sun6i_msgbox *mbox = platform_get_drvdata(pdev);
mbox_controller_unregister(&mbox->controller);
+ free_irq(mbox->irq, mbox);
/* See the comment in sun6i_msgbox_probe about the reset line. */
clk_disable_unprepare(mbox->clk);
}
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-03 8:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-03 8:28 ` [PATCH 01/10] mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure Lee Jones
2026-12-03 10:38 ` Konrad Dybcio
2026-12-03 8:28 ` [PATCH 02/10] mailbox: ti-msgmgr: Use unsigned IDs in ti_msgmgr_of_xlate() Lee Jones
2026-12-03 8:28 ` [PATCH 03/10] mailbox: riscv-sbi-mpxy: Protect per-CPU shmem access with irqsave Lee Jones
2026-12-03 14:32 ` Rahul Pathak
2026-12-03 15:05 ` Lee Jones
2026-12-03 8:28 ` [PATCH 04/10] mailbox: riscv-sbi-mpxy: Validate shmem bounds in message send helpers Lee Jones
2026-12-03 8:28 ` [PATCH 05/10] mailbox: bcm-pdc: Unregister mailbox controller before destroying DMA pools Lee Jones
2026-12-03 8:28 ` [PATCH 06/10] mailbox: qcom-ipcc: Remove IRQ domain via devm to avoid ISR use-after-free Lee Jones
2026-12-03 10:39 ` Konrad Dybcio
2026-12-03 8:28 ` Lee Jones [this message]
2026-12-03 13:43 ` [PATCH 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown Chen-Yu Tsai
2026-12-03 8:28 ` [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown Lee Jones
2026-12-03 13:49 ` Chen-Yu Tsai
2026-12-03 8:28 ` [PATCH 09/10] mailbox: arm_mhu_db: Initialise channel registers before controller registration Lee Jones
2026-12-03 9:40 ` Sudeep Holla
2026-12-03 8:28 ` [PATCH 10/10] mailbox: ti-msgmgr: Return -EIO on queue error in ti_msgmgr_send_data() 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=e17ca9554022bed48cc3b0878e7825ccaf7ba6a6.1796286447.git.lee@kernel.org \
--to=lee@kernel.org \
--cc=jassisinghbrar@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=p.zabel@pengutronix.de \
--cc=samuel@sholland.org \
--cc=stable@vger.kernel.org \
--cc=wens@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®