From: Yige Jiang <yigejiang86@gmail.com>
To: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>,
Vinod Koul <vkoul@kernel.org>
Cc: Yige Jiang <yigejiang86@gmail.com>,
Frank Li <Frank.Li@kernel.org>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH] dmaengine: dw-axi-dmac: Fix channel unregistration on remove
Date: Thu, 3 Dec 2026 14:28:00 +0800 [thread overview]
Message-ID: <20261203032057.d20d61d8715f.dw-axi-dmac@gmail.com> (raw)
dw_remove() deletes every channel from dw->dma.channels. The managed
dma_async_device_unregister() subsequently walks that list to unregister
the channel devices. It finds none, leaving the dma<N>chan<M> devices
registered and their chan_dev->chan pointers uncleared.
Devres then frees dw->chan[], which embeds each dma_chan. Reading the
remaining channel devices' sysfs attributes can dereference freed
memory. The channel devices and their per-CPU counters also leak. The
list was already emptied too early before the conversion to managed
DMA device registration.
Keep the channels on the list and only kill their tasklets in remove.
The interrupts have already been freed, so they cannot schedule more
tasklets. The managed unregister can then clear chan_dev->chan and
unregister the channel devices before the channel array is freed.
Fixes: 1fe20f1b8454 ("dmaengine: Introduce DW AXI DMAC driver")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20260727211146.D154F1F00A3A@smtp.kernel.org/
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on dmaengine next as merged in next-20261201.
Compile-tested on next-20261104: arm64, GCC 14.2.0, W=1,
CONFIG_DW_AXI_DMAC=y and CONFIG_COMPILE_TEST=y.
Baseline and patched objects built without warnings.
The code changes are the same as in that build.
No hardware or runtime test was performed.
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index 7520c78f55ccf69294fdbc055d683469cf8c3078..cf8c4403d7ddae3bd0f3028098346e9a0a526d33 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -1630,7 +1630,7 @@ static void dw_remove(struct platform_device *pdev)
{
struct axi_dma_chip *chip = platform_get_drvdata(pdev);
struct dw_axi_dma *dw = chip->dw;
- struct axi_dma_chan *chan, *_chan;
+ struct axi_dma_chan *chan;
u32 i;
int ret;
@@ -1655,11 +1655,8 @@ static void dw_remove(struct platform_device *pdev)
of_dma_controller_free(chip->dev->of_node);
- list_for_each_entry_safe(chan, _chan, &dw->dma.channels,
- vc.chan.device_node) {
- list_del(&chan->vc.chan.device_node);
+ list_for_each_entry(chan, &dw->dma.channels, vc.chan.device_node)
tasklet_kill(&chan->vc.task);
- }
}
static const struct dev_pm_ops dw_axi_dma_pm_ops = {
base-commit: 2e02fb103be058cf8b2fb24112a74a2715e090f0
reply other threads:[~2026-12-03 6:28 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=20261203032057.d20d61d8715f.dw-axi-dmac@gmail.com \
--to=yigejiang86@gmail.com \
--cc=Eugeniy.Paltsev@synopsys.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 \
/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®