From: Frank Li <Frank.li@oss.nxp.com>
To: Yige Jiang <yigejiang86@gmail.com>
Cc: Vinod Koul <vkoul@kernel.org>, Orson Zhai <orsonzhai@gmail.com>,
Frank Li <Frank.Li@kernel.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Chunyan Zhang <zhang.lyra@gmail.com>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] dmaengine: sprd: Fix channel unregistration on remove
Date: Thu, 3 Dec 2026 11:06:51 -0600 [thread overview]
Message-ID: <axGhq6AUyZ5CSSIN@SMW015318> (raw)
In-Reply-To: <20261203032058.081e844d03ce.sprd-dma@gmail.com>
On Thu, Dec 03, 2026 at 02:28:09PM +0800, Yige Jiang wrote:
> sprd_dma_remove() deletes every channel from sdev->dma_dev.channels
> before calling dma_async_device_unregister(). The latter walks that
> same list to unregister the channel devices, so it finds none. The
> dma<N>chan<M> devices remain registered and their chan_dev->chan
> pointers are not cleared.
>
> Devres then frees sdev, 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.
>
> Keep the channels on the list and only kill their tasklets in remove.
> The interrupt has already been freed, so it cannot schedule more
> tasklets. dma_async_device_unregister() can then clear chan_dev->chan
> and unregister the channel devices before sdev is freed.
>
> Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/all/20260727210723.200551F000E9@smtp.kernel.org/
> Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
> ---
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_SPRD_DMA=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/sprd-dma.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index 60b3067a009945953b9f971fed34a3e2e628c250..9e485ef0b998ced3a80429ac33100b546423bd1d 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -1222,7 +1222,7 @@ err_register:
> static void sprd_dma_remove(struct platform_device *pdev)
> {
> struct sprd_dma_dev *sdev = platform_get_drvdata(pdev);
> - struct sprd_dma_chn *c, *cn;
> + struct sprd_dma_chn *c;
>
> pm_runtime_get_sync(&pdev->dev);
>
> @@ -1230,11 +1230,8 @@ static void sprd_dma_remove(struct platform_device *pdev)
> if (sdev->irq > 0)
> devm_free_irq(&pdev->dev, sdev->irq, sdev);
>
> - list_for_each_entry_safe(c, cn, &sdev->dma_dev.channels,
> - vc.chan.device_node) {
> - list_del(&c->vc.chan.device_node);
> + list_for_each_entry(c, &sdev->dma_dev.channels, vc.chan.device_node)
> tasklet_kill(&c->vc.task);
> - }
>
> of_dma_controller_free(pdev->dev.of_node);
> dma_async_device_unregister(&sdev->dma_dev);
>
> base-commit: 2e02fb103be058cf8b2fb24112a74a2715e090f0
prev parent reply other threads:[~2026-12-03 17:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 6:28 [PATCH] dmaengine: sprd: Fix channel unregistration on remove Yige Jiang
2026-12-03 17:06 ` Frank Li [this message]
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=axGhq6AUyZ5CSSIN@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=orsonzhai@gmail.com \
--cc=stable@vger.kernel.org \
--cc=vkoul@kernel.org \
--cc=yigejiang86@gmail.com \
--cc=zhang.lyra@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