dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pan Chuang" <panchuang@vivo.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH 06/26] dmaengine: mmp_pdma: Remove redundant dev_err()/dev_err_probe()
Date: Thu, 09 Jul 2026 14:08:47 +0000	[thread overview]
Message-ID: <20260709140847.DBA4B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709135846.97972-7-panchuang@vivo.com>

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

Pre-existing issues:
- [High] Potential NULL pointer dereference in IRQ handlers (`mmp_pdma_chan_handler` / `mmp_pdma_int_handler`) when handling spurious or shared interrupts before initialization is complete or when the PHY is inactive.
- [High] Missing `tasklet_kill()` on device removal and probe error paths causes a use-after-free if the tasklet runs after `devres` frees the channel memory.
- [Medium] Negative IRQ error codes like `-EPROBE_DEFER` are incorrectly passed to `devm_request_irq()` and masked as `-EINVAL`.
--

--- Patch [6]: [PATCH 06/26] dmaengine: mmp_pdma: Remove redundant dev_err()/dev_err_probe() ---
commit f205944d00824c4ac830efbda0d25e06f33f54a9
Author: Pan Chuang <panchuang@vivo.com>

dmaengine: mmp_pdma: Remove redundant dev_err()/dev_err_probe()

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

> diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c
> index 386e85cd4882a..c2a638d554883 100644
> --- a/drivers/dma/mmp_pdma.c
> +++ b/drivers/dma/mmp_pdma.c
> @@ -1161,10 +1161,8 @@ static int mmp_pdma_chan_init(struct mmp_pdma_device *pdev, int idx, int irq)
>  	if (irq) {

[Severity: Medium]
This is a pre-existing issue, but could irq be a negative error code here?

If platform_get_irq() returns -EPROBE_DEFER, it evaluates as true in this
condition. It would then be passed directly to devm_request_irq() below,
which implicitly casts it to an unsigned int and fails with -EINVAL, permanently
failing the probe instead of deferring it.

>  		ret = devm_request_irq(pdev->dev, irq, mmp_pdma_chan_handler,
>  				       IRQF_SHARED, "pdma", phy);

[Severity: High]
This isn't a bug introduced by this patch, but is there a risk of a NULL
pointer dereference with these shared IRQs?

In mmp_pdma_probe(), a shared interrupt is requested before the loop that
initializes phy->base in mmp_pdma_chan_init(). If a shared interrupt triggers
immediately, mmp_pdma_int_handler() calls mmp_pdma_chan_handler() and then
clear_chan_irq(), which dereferences phy->base:

drivers/dma/mmp_pdma.c:clear_chan_irq() {
    ...
    u32 dint = readl(phy->base + DINT);
    ...
}

Additionally, if a spurious interrupt fires while phy->vchan is NULL,
clear_chan_irq() can still return 0. This causes mmp_pdma_chan_handler() to
unconditionally execute tasklet_schedule(&phy->vchan->tasklet), which
dereferences NULL.

> -		if (ret) {
> -			dev_err(pdev->dev, "channel request irq fail!\n");
> +		if (ret)
>  			return ret;
> -		}
>  	}
>  
>  	spin_lock_init(&chan->desc_lock);

[Severity: High]
This is a pre-existing issue, but does this driver leave tasklets running
after the channel memory is freed?

A few lines below here in mmp_pdma_chan_init(), a tasklet is set up via
tasklet_setup(). However, mmp_pdma_remove() does not appear to call
tasklet_kill(). 

Since free_irq() synchronizes with running interrupt handlers but not with
scheduled tasklets, if a tasklet was scheduled right before the IRQ was freed,
it could execute after devres has freed the chan memory, causing a
use-after-free.

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

  reply	other threads:[~2026-07-09 14:08 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 [this message]
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
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=20260709140847.DBA4B1F000E9@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;
as well as URLs for NNTP newsgroup(s).