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

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

Pre-existing issues:
- [High] The IRQ is requested before dependent resources are initialized, and the probe error path destroys resources before the devm-managed IRQ is disabled, risking NULL pointer dereferences, uninitialized spinlock access, and Use-After-Free.
- [High] Mismatch between devm-managed DMA registration and manual resource teardown causes sysfs leaks and use-after-free risks in both probe error and remove paths.
--

--- Patch [17]: [PATCH 17/26] dmaengine: st_fdma: Remove redundant dev_err()/dev_err_probe() ---
commit 15a299566b3b9735b597a7ab918fd3926002aefe
Author: Pan Chuang <panchuang@vivo.com>
dmaengine: st_fdma: Remove redundant dev_err()/dev_err_probe()

This commit removes driver-specific error logging for devm_request_irq()
failures in st_fdma_probe(), as the core now automatically logs detailed
error messages on failure.

> diff --git a/drivers/dma/st_fdma.c b/drivers/dma/st_fdma.c
> index d9547017f3bd6..05a2642601e61 100644
> --- a/drivers/dma/st_fdma.c
> +++ b/drivers/dma/st_fdma.c
> @@ -771,10 +771,8 @@ static int st_fdma_probe(struct platform_device *pdev)
>  
>  	ret = devm_request_irq(&pdev->dev, fdev->irq, st_fdma_irq_handler, 0,
>  			       dev_name(&pdev->dev), fdev);
> -	if (ret) {
> -		dev_err(&pdev->dev, "Failed to request irq (%d)\n", ret);
> +	if (ret)
>  		goto err;

[Severity: High]
This is a pre-existing issue, but is it safe to request the IRQ before
allocating fdev->slim_rproc and initializing the channels?

If an interrupt fires immediately after devm_request_irq() is called,
st_fdma_irq_handler() will use fdma_read(), which dereferences
fdev->slim_rproc->peri. Since fdev->slim_rproc is still NULL, would this
cause a crash?

Also, if probe fails later (e.g., during DMA registration), the error
path destroys slim_rproc and kills tasklets:

drivers/dma/st_fdma.c:st_fdma_probe() {
    ...
err_rproc:
	st_fdma_free(fdev);
	st_slim_rproc_put(fdev->slim_rproc);
err:
	return ret;
}

Since the IRQ is managed by devres, it remains active until the devres
cleanup runs. If an interrupt fires during this window, could it access
destroyed resources?

[Severity: High]
This is also a pre-existing issue, but does the error handling in
st_fdma_probe() and the driver remove path create a mismatch with
devm-managed DMA registration?

When probe fails in of_dma_controller_register(), the err_rproc path calls
st_fdma_free() before devres cleanup:

drivers/dma/st_fdma.c:st_fdma_free() {
    ...
	list_del(&fchan->vchan.chan.device_node);
    ...
}

This manual list_del() empties fdev->dma_device.channels. Will this cause
the devres dma_async_device_unregister() to skip unregistering the sysfs
devices, leaving dangling pointers to the freed fdev?

Similarly, in the remove path:

drivers/dma/st_fdma.c:st_fdma_remove() {
	struct st_fdma_dev *fdev = platform_get_drvdata(pdev);

	devm_free_irq(&pdev->dev, fdev->irq, fdev);
	st_slim_rproc_put(fdev->slim_rproc);
	of_dma_controller_free(pdev->dev.of_node);
}

st_fdma_remove() does not call st_fdma_free() to kill the tasklets, and it
puts slim_rproc manually. When devres later frees fdev, could any
scheduled but unkilled tasklet trigger a use-after-free, and could concurrent
clients terminating channels trigger a use-after-free on slim_rproc?

>  
>  	fdev->slim_rproc = st_slim_rproc_alloc(pdev, fdev->fw_name);
>  	if (IS_ERR(fdev->slim_rproc)) {

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

  reply	other threads:[~2026-07-09 14:30 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 [this message]
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
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=20260709143008.9F20A1F00A3D@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