Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Frank.Li@oss.nxp.com
Cc: linux-sunxi@lists.linux.dev, imx@lists.linux.dev,
	linux-trace-kernel@vger.kernel.org, Frank.Li@kernel.org,
	vkoul@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH v4 1/4] dmaengine: vchan: add vchan_chan_name() to get channel device name
Date: Wed, 09 Sep 2026 16:36:40 +0000	[thread overview]
Message-ID: <20260909163640.E26281F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260909-dma-chan_dev-rename-v4-1-d8fb6892a70f@nxp.com>

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

Pre-existing issues:
- [High] Use-After-Free of DMA channel name in probe error path due to devm/manual cleanup mismatch
--

commit 6477701933e50dc5df4ddb73cea43b46ef1b83f8
Author: Frank Li <Frank.Li@nxp.com>

    dmaengine: vchan: add vchan_chan_name() to get channel device name
    
    Introduce vchan_chan_name() to obtain the DMA channel device name.
    
    Use a dedicated helper instead of directly accessing dma_chan::dev
    so callers remain unaffected by an upcoming rename of the struct member.

[ ... ]

> diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
> index d3ad78562a140..3e8151e2ad75a 100644
> --- a/drivers/dma/stm32/stm32-dma.c
> +++ b/drivers/dma/stm32/stm32-dma.c
> @@ -1668,7 +1668,7 @@ static int stm32_dma_probe(struct platform_device *pdev)
>  
>  		ret = devm_request_irq(&pdev->dev, chan->irq,
>  				       stm32_dma_chan_irq, 0,
> -				       dev_name(chan2dev(chan)), chan);
> +				       vchan_chan_name(&chan->vchan), chan);
>  		if (ret) {
>  			dev_err(&pdev->dev,
>  				"request_irq failed with err %d channel %d\n",

[Severity: High]
This is a pre-existing issue, but in drivers/dma/stm32/stm32-dma.c at
stm32_dma_probe(), devm_request_irq() stores the dynamically allocated DMA
channel name (vchan_chan_name()) as the IRQ name.

If a subsequent initialization step fails, such as a failure in
of_dma_controller_register(), the code jumps to err_unregister:

drivers/dma/stm32/stm32-dma.c:stm32_dma_probe() {
    ...
err_unregister:
	dma_async_device_unregister(dd);
    ...
}

Because dma_async_device_unregister() is called manually, it frees the DMA
device and its associated channel name string immediately. However, since the
IRQ is managed by devm, its cleanup is deferred until devres runs after probe
returns.

Could this create a use-after-free window where the IRQ subsystem retains a
dangling pointer to the freed string? If an interrupt fires or if a user
reads /proc/interrupts concurrently during this window, could this lead to an
oops or memory corruption?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260909-dma-chan_dev-rename-v4-0-d8fb6892a70f@nxp.com?part=1

  reply	other threads:[~2026-09-09 16:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 16:22 [PATCH v4 0/4] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity Frank.Li
2026-09-09 16:22 ` [PATCH v4 1/4] dmaengine: vchan: add vchan_chan_name() to get channel device name Frank.Li
2026-09-09 16:36   ` sashiko-bot [this message]
2026-09-09 16:22 ` [PATCH v4 2/4] dmaengine: use dma_chan_name() helper to get per-channel " Frank.Li
2026-09-09 16:22 ` [PATCH v4 3/4] dmaengine: add (dmaengine|vchan)_chan_dev() helper Frank.Li
2026-09-09 16:22 ` [PATCH v4 4/4] dmaengine: add union chan_dev for dma_chan::dev for clarity Frank.Li
2026-09-09 16:32   ` sashiko-bot

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=20260909163640.E26281F00893@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