DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Frank.Li@oss.nxp.com
Cc: imx@lists.linux.dev, linux-sunxi@lists.linux.dev,
	linux-trace-kernel@vger.kernel.org, Frank.Li@kernel.org,
	dmaengine@vger.kernel.org, vkoul@kernel.org
Subject: Re: [PATCH v2 2/3] dmaengine: use dma_chan_name() helper to get per-channel device name
Date: Thu, 03 Sep 2026 21:05:12 +0000	[thread overview]
Message-ID: <20260903210512.6571A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903-dma-chan_dev-rename-v2-2-0db305b6c716@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Tasklets created for DMA channels are not killed during driver removal, risking use-after-free panics if scheduled after devm allocations are freed.
--

commit fe57b7262d586b3f961d1d34cf7a9a0acf70d3c7
Author: Frank Li <Frank.Li@nxp.com>

dmaengine: use dma_chan_name() helper to get per-channel device name

This commit updates various DMA engine drivers to use the existing
dma_chan_name() helper instead of open-coding the per-channel device name
retrieval. The change simplifies the code and improves consistency across
the subsystem without altering functionality.

[ ... ]

> diff --git a/drivers/dma/loongson/loongson2-apb-dma.c b/drivers/dma/loongson/loongson2-apb-dma.c
> index aceb069e71fca..7c3d7c3273955 100644
> --- a/drivers/dma/loongson/loongson2-apb-dma.c
> +++ b/drivers/dma/loongson/loongson2-apb-dma.c
> @@ -282,7 +282,7 @@ static int ls2x_dma_alloc_chan_resources(struct dma_chan *chan)
>  	struct ls2x_dma_chan *lchan = to_ldma_chan(chan);
>  
>  	/* Create a pool of consistent memory blocks for hardware descriptors */
> -	lchan->pool = dma_pool_create(dev_name(chan2dev(chan)),
> +	lchan->pool = dma_pool_create(dma_chan_name(chan),
>  				      chan->device->dev, PAGE_SIZE,
>  				      __alignof__(struct ls2x_dma_hw_desc), 0);
>  	if (!lchan->pool) {

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a pre-existing
issue in ls2x_dma_remove() missing tasklet cleanup.

Should ls2x_dma_remove() iterate over the channels and call
tasklet_kill(&chan->vchan.task) before returning?

The driver relies on devm allocations for channel memory, which are
automatically freed immediately after remove() completes. If the DMA driver
is unbound shortly after an interrupt fires, the interrupt handler schedules
the channel's tasklet. If this scheduled tasklet executes after the memory
is freed, can it dereference invalid memory and cause a use-after-free
panic?

[ ... ]

> diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c
> index 386e85cd4882a..6b29e15b0616c 100644
> --- a/drivers/dma/mmp_pdma.c
> +++ b/drivers/dma/mmp_pdma.c
> @@ -565,7 +565,7 @@ static int mmp_pdma_alloc_chan_resources(struct dma_chan *dchan)
>  	if (chan->desc_pool)
>  		return 1;
>  
> -	chan->desc_pool = dma_pool_create(dev_name(&dchan->dev->device),
> +	chan->desc_pool = dma_pool_create(dma_chan_name(dchan),
>  					  chan->dev,
>  					  sizeof(struct mmp_pdma_desc_sw),
>  					  __alignof__(struct mmp_pdma_desc_sw),

[Severity: High]
This isn't a bug introduced by this patch, but there appears to be a similar
pre-existing issue in mmp_pdma_remove().

Does mmp_pdma_remove() also need a loop over the channels to call
tasklet_kill(&chan->tasklet)?

Like the Loongson driver, this driver also uses devm allocations for
channel structures and could experience a use-after-free panic if a tasklet
runs after mmp_pdma_remove() finishes and the memory is freed.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903-dma-chan_dev-rename-v2-0-0db305b6c716@nxp.com?part=2

  reply	other threads:[~2026-09-03 21:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 20:53 [PATCH v2 0/3] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity Frank.Li
2026-09-03 20:53 ` [PATCH v2 1/3] dmaengine: vchan: add vchan_chan_name() to get channel device name Frank.Li
2026-09-03 21:03   ` sashiko-bot
2026-09-03 22:30   ` Logan Gunthorpe
2026-09-04  8:35   ` Amelie Delaunay
2026-09-04  9:10     ` [Linux-stm32] " Amelie Delaunay
2026-09-04 14:21       ` Frank Li
2026-09-04  9:08   ` Andy Shevchenko
2026-09-04  9:26     ` Amelie Delaunay
2026-09-04 11:38       ` Andy Shevchenko
2026-09-03 20:53 ` [PATCH v2 2/3] dmaengine: use dma_chan_name() helper to get per-channel " Frank.Li
2026-09-03 21:05   ` sashiko-bot [this message]
2026-09-03 20:53 ` [PATCH v2 3/3] dmaengine: add union chan_dev for dma_chan::dev for clarity Frank.Li
2026-09-03 21:03   ` sashiko-bot
2026-09-04  9:19   ` Andy Shevchenko

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=20260903210512.6571A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=Frank.Li@oss.nxp.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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