All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: vkoul@kernel.org, dmaengine@vger.kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH] dmaengine: at_hdmac: ioremap and get irq early
Date: Thu, 23 Jul 2026 05:16:49 +0000	[thread overview]
Message-ID: <20260723051649.D75A21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723050606.283453-1-rosenp@gmail.com>

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

Pre-existing issues:
- [High] Use-After-Free due to missing tasklet_kill() on driver removal
--

--- Patch [1]: [PATCH] dmaengine: at_hdmac: ioremap and get irq early ---
commit c590e127b59a7e207f5a617b28aad848c06bc09b
Author: Rosen Penev <rosenp@gmail.com>

    dmaengine: at_hdmac: ioremap and get irq early
    
This commit updates the driver to map I/O memory and retrieve the IRQ early
during probe. By performing these operations before allocating memory and
configuring the DMA controller, it avoids unnecessary work if they return
-EPROBE_DEFER.

> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index e5b30a57c477a..2f6f5877fc3cc 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
[ ... ]
> @@ -1968,13 +1977,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
>  	if (!atdma)
>  		return -ENOMEM;
>  
> -	atdma->regs = devm_platform_ioremap_resource(pdev, 0);
> -	if (IS_ERR(atdma->regs))
> -		return PTR_ERR(atdma->regs);
> -
> -	irq = platform_get_irq(pdev, 0);
> -	if (irq < 0)
> -		return irq;
> +	atdma->regs = regs;
>  
>  	/* discover transaction capabilities */
>  	atdma->dma_device.cap_mask = plat_dat->cap_mask;

[Severity: High]
This is a pre-existing issue, but does at_dma_remove() need to call
tasklet_kill() to prevent a use-after-free during driver removal?

If an interrupt fires just before driver removal or device unbind, it can
schedule a channel tasklet via vchan_cookie_complete(), leaving it in the
scheduler queue.

at_dma_remove() cleans up the channels but doesn't kill the tasklets:

drivers/dma/at_hdmac.c:at_dma_remove() {
...
	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);
	}
...
}

When at_dma_remove() returns, the devres mechanism frees the at_dma
structure containing the tasklet structs.

If a pending tasklet executes on the freed memory, can it cause a
use-after-free and memory corruption?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260723050606.283453-1-rosenp@gmail.com?part=1

      reply	other threads:[~2026-07-23  5:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  5:06 [PATCH] dmaengine: at_hdmac: ioremap and get irq early Rosen Penev
2026-07-23  5:16 ` 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=20260723051649.D75A21F000E9@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.