DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pan Chuang" <panchuang@vivo.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH 20/26] dmaengine: stm32-stm32-mdma: Remove redundant dev_err()/dev_err_probe()
Date: Thu, 09 Jul 2026 14:32:57 +0000	[thread overview]
Message-ID: <20260709143258.1F5601F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709135846.97972-21-panchuang@vivo.com>

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

Pre-existing issues:
- [High] Missing `.remove` callback causes resource leaks and use-after-free on driver unbind.
- [High] Devres leak of DMA pools on channel allocation error path.
- [High] Disabling the clock before freeing the IRQ on the probe error path can cause a synchronous external abort.
--

--- Patch [20]: [PATCH 20/26] dmaengine: stm32-stm32-mdma: Remove redundant dev_err()/dev_err_probe() ---
commit 6440956ea9b4ed6aa697c4eb90a3a35f158a8e26
Author: Pan Chuang <panchuang@vivo.com>

dmaengine: stm32-stm32-mdma: Remove redundant dev_err()/dev_err_probe()

This patch removes redundant dev_err() calls after devm_request_irq() 
since the core now logs detailed error messages automatically.

> diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
> --- a/drivers/dma/stm32/stm32-mdma.c
> +++ b/drivers/dma/stm32/stm32-mdma.c
> @@ -1713,10 +1713,8 @@ static int stm32_mdma_probe(struct platform_device *pdev)
>  
>  	ret = devm_request_irq(&pdev->dev, dmadev->irq, stm32_mdma_irq_handler,
>  			       0, dev_name(&pdev->dev), dmadev);
> -	if (ret) {
> -		dev_err(&pdev->dev, "failed to request IRQ\n");
> +	if (ret)
>  		goto err_clk;

[Severity: High]
This is a pre-existing issue, but does disabling the clock on the error path
before devres frees the IRQ risk a synchronous external abort?

If a spurious interrupt arrives after the goto err_clk path calls
clk_disable_unprepare() but before devres cleans up the IRQ handler,
stm32_mdma_irq_handler() will execute.

Could attempting to read STM32_MDMA_GISR0 while the APB clock is disabled
cause a bus fault and crash the kernel?

>  
>  	ret = dmaenginem_async_device_register(dd);
>  	if (ret)

I also noticed a couple of other pre-existing issues in this file:

drivers/dma/stm32/stm32-mdma.c:stm32_mdma_driver

static struct platform_driver stm32_mdma_driver = {
	.probe = stm32_mdma_probe,
	.driver = {
		.name = "stm32-mdma",
...

[Severity: High]
This is a pre-existing issue, but does this platform driver lack a .remove
callback?

Since suppress_bind_attrs is not set, a privileged user can unbind the
driver via sysfs. When devres frees the device memory for dmadev,
of_dma_controller_free() is never called, leaving a dangling pointer
in the global of_dma_list.

Will subsequent DMA requests by other devices dereference this freed
pointer? Also, could scheduled vchan tasklets cause a use-after-free if
they execute during unbind?


drivers/dma/stm32/stm32-mdma.c:stm32_mdma_alloc_chan_resources()

	...
	ret = pm_runtime_resume_and_get(dmadev->ddev.dev);
	if (ret < 0)
		return ret;

	ret = stm32_mdma_disable_chan(chan);
	if (ret < 0)
		goto err_pm;
	...
err_pm:
	pm_runtime_put(dmadev->ddev.dev);
	return ret;

[Severity: High]
This is a pre-existing issue, but does this error path leak the descriptor
pool?

Earlier in stm32_mdma_alloc_chan_resources(), dmam_pool_create() allocates
a new pool. If a subsequent step like pm_runtime_resume_and_get() or
stm32_mdma_disable_chan() fails, the function returns without destroying
the pool.

Since the DMA engine core does not call the free callback if allocation
fails, could repeated channel requests by userspace continuously accumulate
leaked DMA pools and lead to an out of memory condition?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260709135846.97972-1-panchuang@vivo.com?part=20

  reply	other threads:[~2026-07-09 14:32 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 13:58 [PATCH 00/26] dmaengine: Remove redundant error messages on IRQ request failure Pan Chuang
2026-07-09 13:58 ` [PATCH 01/26] dmaengine: fsl-edma-main: Remove redundant dev_err()/dev_err_probe() Pan Chuang
2026-07-09 14:12   ` sashiko-bot
2026-07-09 14:33   ` Frank Li
2026-07-09 13:58 ` [PATCH 02/26] dmaengine: fsl-qdma: " Pan Chuang
2026-07-09 14:08   ` sashiko-bot
2026-07-09 14:34   ` Frank Li
2026-07-09 13:58 ` [PATCH 03/26] dmaengine: loongson-loongson1-apb-dma: " Pan Chuang
2026-07-09 14:11   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 04/26] dmaengine: mediatek-mtk-cqdma: " Pan Chuang
2026-07-09 14:10   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 05/26] dmaengine: mediatek-mtk-hsdma: " Pan Chuang
2026-07-09 14:10   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 06/26] dmaengine: mmp_pdma: " Pan Chuang
2026-07-09 14:08   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 07/26] dmaengine: moxart-dma: " Pan Chuang
2026-07-09 14:16   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 08/26] dmaengine: owl-dma: " Pan Chuang
2026-07-09 14:16   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 09/26] dmaengine: pxa_dma: " Pan Chuang
2026-07-09 14:20   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 10/26] dmaengine: qcom-gpi: " Pan Chuang
2026-07-09 14:19   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 11/26] dmaengine: sf-pdma-sf-pdma: " Pan Chuang
2026-07-09 14:18   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 12/26] dmaengine: sh-rcar-dmac: " Pan Chuang
2026-07-09 14:23   ` sashiko-bot
2026-07-09 14:31   ` Geert Uytterhoeven
2026-07-09 13:58 ` [PATCH 13/26] dmaengine: sh-rz-dmac: " Pan Chuang
2026-07-09 14:32   ` Geert Uytterhoeven
2026-07-09 13:58 ` [PATCH 14/26] dmaengine: sh-shdmac: " Pan Chuang
2026-07-09 14:24   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 15/26] dmaengine: sh-usb-dmac: " Pan Chuang
2026-07-09 14:27   ` sashiko-bot
2026-07-09 14:33   ` Geert Uytterhoeven
2026-07-09 13:58 ` [PATCH 16/26] dmaengine: sprd-dma: " Pan Chuang
2026-07-09 14:27   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 17/26] dmaengine: st_fdma: " Pan Chuang
2026-07-09 14:30   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 18/26] dmaengine: stm32-stm32-dma: " Pan Chuang
2026-07-09 14:30   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 19/26] dmaengine: stm32-stm32-dma3: " Pan Chuang
2026-07-09 14:33   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 20/26] dmaengine: stm32-stm32-mdma: " Pan Chuang
2026-07-09 14:32   ` sashiko-bot [this message]
2026-07-09 13:58 ` [PATCH 21/26] dmaengine: sun4i-dma: " Pan Chuang
2026-07-09 14:35   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 22/26] dmaengine: sun6i-dma: " Pan Chuang
2026-07-09 13:58 ` [PATCH 23/26] dmaengine: tegra20-apb-dma: " Pan Chuang
2026-07-09 13:58 ` [PATCH 24/26] dmaengine: ti-edma: " Pan Chuang
2026-07-09 14:38   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 25/26] dmaengine: uniphier-xdmac: " Pan Chuang
2026-07-09 14:41   ` sashiko-bot
2026-07-09 13:58 ` [PATCH 26/26] dmaengine: xgene-dma: " Pan Chuang
2026-07-09 14:39   ` sashiko-bot
2026-07-09 14:26 ` [PATCH 00/26] dmaengine: Remove redundant error messages on IRQ request failure Wolfram Sang

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=20260709143258.1F5601F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=panchuang@vivo.com \
    --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