From: hyunjungg <hj351016@gmail.com>
To: Vinod Koul <vkoul@kernel.org>
Cc: Frank Li <Frank.Li@kernel.org>,
Zhangfei Gao <zhangfei.gao@marvell.com>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Hyunjung Ko <hj351016@gmail.com>
Subject: [PATCH] dmaengine: mmp_pdma: kill tasklet on channel teardown
Date: Mon, 9 Nov 2026 17:09:44 +0900 [thread overview]
Message-ID: <20261109080944.1368218-1-hj351016@gmail.com> (raw)
From: Hyunjung Ko <hj351016@gmail.com>
The per-channel completion tasklet (dma_do_tasklet) is scheduled from the
channel interrupt handler but is never torn down. mmp_pdma_remove() frees
the interrupts and unregisters the DMA device, but the channel objects --
and with them the tasklet_struct -- are devm-allocated and are therefore
freed only after .remove() returns. A tasklet scheduled just before the
interrupt was freed can still be pending at that point, so it runs against
freed memory (use-after-free).
Kill each channel's tasklet after the interrupts have been freed (so none
can be re-scheduled) and before the DMA device is unregistered, mirroring
the teardown fixes applied to other dmaengine drivers.
Fixes: c8acd6aa6bed ("dmaengine: mmp-pdma support")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunjung Ko <hj351016@gmail.com>
---
drivers/dma/mmp_pdma.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c
index 8abd24e..2f0de65 100644
--- a/drivers/dma/mmp_pdma.c
+++ b/drivers/dma/mmp_pdma.c
@@ -1119,6 +1119,7 @@ static void mmp_pdma_remove(struct platform_device *op)
{
struct mmp_pdma_device *pdev = platform_get_drvdata(op);
struct mmp_pdma_phy *phy;
+ struct dma_chan *chan;
int i, irq = 0, irq_num = 0;
if (op->dev.of_node)
@@ -1140,6 +1141,14 @@ static void mmp_pdma_remove(struct platform_device *op)
}
}
+ /*
+ * The interrupts are gone now, so no new work can be scheduled.
+ * Kill any tasklet that is still pending before the channels are
+ * freed, otherwise it would run against freed memory.
+ */
+ list_for_each_entry(chan, &pdev->device.channels, device_node)
+ tasklet_kill(&to_mmp_pdma_chan(chan)->tasklet);
+
dma_async_device_unregister(&pdev->device);
}
--
2.43.0
reply other threads:[~2026-11-09 8:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261109080944.1368218-1-hj351016@gmail.com \
--to=hj351016@gmail.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=vkoul@kernel.org \
--cc=zhangfei.gao@marvell.com \
/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®