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

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

Pre-existing issues:
- [High] Incorrect Optional Resource Handling / Ignored Probe Deferral
- [High] Premature IRQ Request Causes Potential NULL Pointer Dereference
- [High] Missing Tasklet Cleanup on Probe Failure Leads to Use-After-Free
--

--- Patch [16]: [PATCH 16/26] dmaengine: sprd-dma: Remove redundant dev_err()/dev_err_probe() ---
commit e390b8344f4bfbd854daa3d432e12e9099d1828c
Author: Pan Chuang <panchuang@vivo.com>

dmaengine: sprd-dma: Remove redundant dev_err()/dev_err_probe()

The devm_request_irq() now automatically logs detailed error messages on
failure. This eliminates the need for driver-specific dev_err() and
dev_err_probe() calls that previously printed generic messages.

> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index 087fea3af2e41..dbf52ff88b47e 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -1162,10 +1162,8 @@ static int sprd_dma_probe(struct platform_device *pdev)
>  	if (sdev->irq > 0) {

[Severity: High]
This is a pre-existing issue, but does this correctly handle probe deferral?

If platform_get_irq() returns -EPROBE_DEFER, the check if (sdev->irq > 0) 
ignores it and the driver will start without its IRQ. 

A similar issue exists earlier in this function with the ashb_eb clock:

	sdev->ashb_clk = devm_clk_get(&pdev->dev, "ashb_eb");
	if (IS_ERR(sdev->ashb_clk))
		dev_warn(&pdev->dev, "no optional ashb eb clock\n");

If devm_clk_get() returns -EPROBE_DEFER, the driver merely prints a warning
and continues. If the hardware actually requires this clock, accessing the 
DMA registers unclocked could cause a bus error and freeze the system.

Should this code use devm_clk_get_optional() and platform_get_irq_optional(),
and explicitly propagate errors like -EPROBE_DEFER?

>  		ret = devm_request_irq(&pdev->dev, sdev->irq, dma_irq_handle,
>  				       0, "sprd_dma", (void *)sdev);

[Severity: High]
This is a pre-existing issue, but can this early IRQ request cause a NULL
pointer dereference?

The interrupt is requested and enabled here, but sdev->glb_base is mapped 
afterwards:

	sdev->glb_base = devm_platform_ioremap_resource(pdev, 0);

If the IRQ line is already active (e.g., from the bootloader or kexec),
dma_irq_handle() will trigger immediately and try to read from glb_base:

	struct sprd_dma_dev *sdev = (struct sprd_dma_dev *)dev_id;
	u32 irq_status = readl(sdev->glb_base + SPRD_DMA_GLB_INT_MSK_STS);

Since sdev->glb_base hasn't been mapped yet, this will dereference a NULL
pointer. Should the IRQ request be deferred until all hardware mappings and
internal channel structures are fully initialized?

> -		if (ret < 0) {
> -			dev_err(&pdev->dev, "request dma irq failed\n");
> +		if (ret < 0)
>  			return ret;
> -		}
>  	} else {
>  		dev_warn(&pdev->dev, "no interrupts for the dma controller\n");
>  	}

[Severity: High]
This is a pre-existing issue, but does the probe error path leak scheduled
tasklets leading to a use-after-free?

During vchan_init(), tasklets are set up for each channel. If a late probe 
step fails (like of_dma_controller_register()), the error path handles
cleanup:

err_of_register:
	dma_async_device_unregister(&sdev->dma_dev);
err_register:
	pm_runtime_put_noidle(&pdev->dev);
	pm_runtime_disable(&pdev->dev);
err_rpm:
	sprd_dma_disable(sdev);
	return ret;

However, this doesn't call tasklet_kill() for the channels. If an interrupt 
fired or a channel was used, the tasklet remains scheduled. When devres 
subsequently frees the sdev memory, the scheduled tasklet will execute and
access freed memory, causing a panic. 

Should the error rollback path manually call tasklet_kill() for all 
initialized channels?

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

  reply	other threads:[~2026-07-09 14:27 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 [this message]
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
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=20260709142754.0E92F1F000E9@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