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 04/26] dmaengine: mediatek-mtk-cqdma: Remove redundant dev_err()/dev_err_probe()
Date: Thu, 09 Jul 2026 14:10:27 +0000 [thread overview]
Message-ID: <20260709141028.335C31F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260709135846.97972-5-panchuang@vivo.com>
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
Pre-existing issues:
- [High] IRQ is requested and enabled before tasklets are initialized, leading to a crash.
- [High] The IRQ handler accesses unallocated channel structures, causing a NULL pointer dereference.
- [High] Device registers are accessed before clocks and power management are enabled, due to premature device registration.
- [High] Missing OF DMA controller deregistration on hardware initialization failure.
- [High] Missing cleanup for virtual channel tasklets on the probe error path leads to a potential Use-After-Free.
- [High] Teardown asymmetry in the device removal routine allows concurrent access to destroyed state.
--
--- Patch [4]: [PATCH 04/26] dmaengine: mediatek-mtk-cqdma: Remove redundant dev_err()/dev_err_probe() ---
commit 04c062c96653e2015152bd44faa0dd41edc7a398
Author: Pan Chuang <panchuang@vivo.com>
dmaengine: mediatek-mtk-cqdma: Remove redundant dev_err()/dev_err_probe()
This commit removes redundant dev_err() calls when devm_request_irq() fails
in mtk_cqdma_probe(), relying on the core's built-in logging instead. It also
simplifies the error path by returning -EINVAL directly.
> diff --git a/drivers/dma/mediatek/mtk-cqdma.c b/drivers/dma/mediatek/mtk-cqdma.c
> index 80791e30aec24..4dbe84954de6b 100644
> --- a/drivers/dma/mediatek/mtk-cqdma.c
> +++ b/drivers/dma/mediatek/mtk-cqdma.c
> @@ -828,11 +828,8 @@ static int mtk_cqdma_probe(struct platform_device *pdev)
> err = devm_request_irq(&pdev->dev, cqdma->pc[i]->irq,
> mtk_cqdma_irq, 0, dev_name(&pdev->dev),
> cqdma);
[Severity: High]
This is a pre-existing issue, but is it safe to request and enable the IRQ
here before the required tasklet is initialized?
If a pending hardware interrupt fires before tasklet_setup() is called at
the end of the probe function, won't the interrupt handler mtk_cqdma_irq()
execute and call tasklet_schedule() on a zero-initialized tasklet structure?
[Severity: High]
This is also a pre-existing issue, but does the IRQ handler safely handle
unallocated channels?
Physical channels (cqdma->pc[i]) are allocated and their IRQs requested
sequentially in this loop. If an interrupt fires for an earlier channel
(e.g., i=0) before the loop allocates the remaining channels,
mtk_cqdma_irq() executes and blindly iterates over all channels
(0 to cqdma->dma_channels - 1) attempting to lock cqdma->pc[i]->lock.
Could this result in a NULL pointer dereference for the unallocated
channels?
> - if (err) {
> - dev_err(&pdev->dev,
> - "request_irq failed with err %d\n", err);
> + if (err)
> return -EINVAL;
> - }
> }
>
> /* allocate resource for VCs */
While reviewing this patch, I noticed a few other pre-existing issues in
this driver:
drivers/dma/mediatek/mtk-cqdma.c:mtk_cqdma_probe() {
...
err = dma_async_device_register(dd);
...
err = mtk_cqdma_hw_init(cqdma);
...
}
[Severity: High]
This isn't a bug introduced by this patch, but are device registers accessed
before clocks and power management are enabled?
dma_async_device_register() exposes the DMA engine to clients. If a client
immediately requests a channel, mtk_cqdma_alloc_chan_resources() is called,
which invokes mtk_cqdma_hard_reset() to write to device registers.
However, mtk_cqdma_hw_init(), which enables the device clocks and power
management, is called after registration.
Can the register writes occur with disabled clocks causing a synchronous
external abort?
drivers/dma/mediatek/mtk-cqdma.c:mtk_cqdma_probe() {
...
err = of_dma_controller_register(pdev->dev.of_node,
of_dma_xlate_by_chan_id, cqdma);
...
err_unregister:
dma_async_device_unregister(dd);
return err;
}
[Severity: High]
This isn't a bug introduced by this patch, but does the error path leak the
OF DMA controller registration?
If mtk_cqdma_hw_init() fails, the code jumps to err_unregister. The error
path calls dma_async_device_unregister() but fails to call
of_dma_controller_free(pdev->dev.of_node).
Could this leave the device registered in the OF DMA list with a freed
driver context?
drivers/dma/mediatek/mtk-cqdma.c:mtk_cqdma_probe() {
...
for (i = 0; i < cqdma->dma_requests; i++) {
vc = &cqdma->vc[i];
vc->vc.desc_free = mtk_cqdma_vdesc_free;
vchan_init(&vc->vc, dd);
init_completion(&vc->issue_completion);
}
...
err_unregister:
dma_async_device_unregister(dd);
return err;
}
[Severity: High]
This isn't a bug introduced by this patch, but is there missing cleanup for
virtual channel tasklets on the probe error path?
vchan_init() sets up virtual channel tasklets. If a subsequent
initialization step (like mtk_cqdma_hw_init) fails, the err_unregister path
does not call tasklet_kill() for these channels.
Because the device was temporarily exposed via dma_async_device_register(),
a client could have scheduled a transaction, leaving the tasklet active.
When devres frees the device memory, could the executing tasklet trigger a
use-after-free?
drivers/dma/mediatek/mtk-cqdma.c:mtk_cqdma_remove() {
...
/* internal driver state torn down here */
...
dma_async_device_unregister(&cqdma->ddev);
of_dma_controller_free(pdev->dev.of_node);
}
[Severity: High]
This isn't a bug introduced by this patch, but does the teardown asymmetry
in the device removal routine allow concurrent access to destroyed state?
In mtk_cqdma_remove(), internal driver state (tasklets and hardware
clocks/interrupts) is torn down before the subsystem interfaces
(dma_async_device_unregister and of_dma_controller_free) are unregistered.
Does this teardown inversion allow clients to issue new DMA requests while
the driver is actively being destroyed?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709135846.97972-1-panchuang@vivo.com?part=4
next prev parent reply other threads:[~2026-07-09 14:10 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 [this message]
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
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=20260709141028.335C31F00A3A@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