From: Frank Li <Frank.li@oss.nxp.com>
To: Yige Jiang <yigejiang86@gmail.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>,
Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] dmaengine: dw-axi-dmac: Fix channel unregistration on remove
Date: Thu, 3 Dec 2026 11:10:31 -0600 [thread overview]
Message-ID: <axGih9WWVJHyeLHk@SMW015318> (raw)
In-Reply-To: <20261203032057.d20d61d8715f.dw-axi-dmac@gmail.com>
On Thu, Dec 03, 2026 at 02:28:00PM +0800, Yige Jiang wrote:
> 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>
> ---
Can you combine similar fixes of the same subsystem to one patch series
next time.
Reviewed-by: Frank Li <Frank.Li@nxp.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
next prev parent reply other threads:[~2026-12-03 17:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 6:28 [PATCH] dmaengine: dw-axi-dmac: Fix channel unregistration on remove Yige Jiang
2026-12-03 17:10 ` Frank Li [this message]
2026-12-03 17:14 ` Yige Jiang
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=axGih9WWVJHyeLHk@SMW015318 \
--to=frank.li@oss.nxp.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 \
--cc=yigejiang86@gmail.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