From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCHv2] dmaengine: at_hdmac: use more devm in _probe
Date: Fri, 24 Jul 2026 23:08:16 +0000 [thread overview]
Message-ID: <20260724230817.2D4AA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724225720.43410-1-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing tasklet_kill() for vchan tasklets during device removal leads to a potential use-after-free.
- [High] The driver does not implement the device_synchronize callback required for vchan.
--
--- Patch [1]: [PATCHv2] dmaengine: at_hdmac: use more devm in _probe ---
commit 4a21134962b742ca7876c61c580dce0a0982f3d7
Author: Rosen Penev <rosenp@gmail.com>
dmaengine: at_hdmac: use more devm in _probe
As devm is already used in _probe, complete the conversion so that everything
unwinds in proper order.
> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index e5b30a57c477a..f16cf29ca5487 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
[ ... ]
> @@ -2080,10 +2074,10 @@ static int __init at_dma_probe(struct platform_device *pdev)
> dma_has_cap(DMA_SLAVE, atdma->dma_device.cap_mask) ? "slave " : "",
> plat_dat->nr_channels);
>
> - err = dma_async_device_register(&atdma->dma_device);
> + err = dmaenginem_async_device_register(&atdma->dma_device);
[Severity: High]
This is a pre-existing issue, but I noticed that atdma->dma_device does not
implement the device_synchronize callback.
Client drivers call dmaengine_synchronize() to ensure all transfers and their
callbacks have completed before freeing buffers. Because at_hdmac defers
descriptor completion to a tasklet via vchan but omits the device_synchronize
callback, dmaengine_synchronize() becomes a no-op.
Could this lead to client drivers freeing memory while the tasklet is still
actively running or queued, causing a use-after-free or data corruption?
Should device_synchronize be mapped to vchan_synchronize?
> if (err) {
> dev_err(&pdev->dev, "Unable to register: %d.\n", err);
> - goto err_dma_async_device_register;
> + return err;
> }
[ ... ]
> @@ -2121,22 +2103,12 @@ static void at_dma_remove(struct platform_device *pdev)
> struct dma_chan *chan, *_chan;
>
> at_dma_off(atdma);
> - if (pdev->dev.of_node)
> - of_dma_controller_free(pdev->dev.of_node);
> - dma_async_device_unregister(&atdma->dma_device);
> -
> - dma_pool_destroy(atdma->memset_pool);
> - dma_pool_destroy(atdma->lli_pool);
> - free_irq(platform_get_irq(pdev, 0), atdma);
>
> list_for_each_entry_safe(chan, _chan, &atdma->dma_device.channels,
> device_node) {
> /* Disable interrupts */
> atc_disable_chan_irq(atdma, chan->chan_id);
> - list_del(&chan->device_node);
[Severity: High]
This is a pre-existing issue, but it seems there is no tasklet_kill() called
for the vchan tasklets during device removal in at_dma_remove().
If a DMA channel tasklet is scheduled by an interrupt just before device
removal (for example, via sysfs unbind), at_dma_remove() might execute and
return without killing the vchan tasklets. Devres would then subsequently
destroy the lli_pool and free the at_dma structure.
If the pending softirq tasklet executes after this, could it access the freed
pool and cause a use-after-free?
> }
> -
> - clk_disable_unprepare(atdma->clk);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724225720.43410-1-rosenp@gmail.com?part=1
prev parent reply other threads:[~2026-07-24 23:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 22:57 [PATCHv2] dmaengine: at_hdmac: use more devm in _probe Rosen Penev
2026-07-24 23:08 ` sashiko-bot [this message]
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=20260724230817.2D4AA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=rosenp@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.