From: sashiko-bot@kernel.org
To: "Ziheng Wei" <zihengw03@163.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH] dmaengine: at_xdmac: handle empty transfer list in tx_status
Date: Sun, 15 Nov 2026 08:19:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-215288@kernel.org> (raw)
In-Reply-To: <20261115080245.910534-1-zihengw03@163.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] dmaengine: at_xdmac: unchecked list_first_entry() in
at_xdmac_tasklet() [1]
--
commit 7130c1ad653839b18d68794e4d33147aad0531b5
Author: Ziheng Wei <zihengw03@163.com>
dmaengine: at_xdmac: handle empty transfer list in tx_status
This commit uses list_first_entry_or_null() in at_xdmac_tx_status() and
reports a zero residue when atchan->xfers_list is empty after channel
termination.
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index ef0dfe9d37ba3..bcfbb41ea4bc1 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -1553,7 +1553,16 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
>
> spin_lock_irqsave(&atchan->lock, flags);
>
> - desc = list_first_entry(&atchan->xfers_list, struct at_xdmac_desc, xfer_node);
> + desc = list_first_entry_or_null(&atchan->xfers_list, struct at_xdmac_desc,
> + xfer_node);
> + /*
> + * The list is empty once the channel has been terminated, while the
> + * cookie of the terminated transfer is still reported as in progress.
> + */
> + if (!desc) {
> + dma_set_residue(txstate, 0);
> + goto spin_unlock;
> + }
[Severity: High]
This problem wasn't introduced by this patch, but can at_xdmac_tasklet()
and at_xdmac_handle_error() also call list_first_entry() on an empty
atchan->xfers_list [1]?
CPU0 CPU1
at_xdmac_interrupt()
atchan->irq_status = ...
tasklet_schedule(&atchan->tasklet)
at_xdmac_device_terminate_all()
spin_lock_irqsave(&atchan->lock)
list_del(&desc->xfer_node)
clear_bit(AT_XDMAC_CHAN_IS_CYCLIC)
spin_unlock_irqrestore(...)
at_xdmac_tasklet()
spin_lock_irq(&atchan->lock)
desc = list_first_entry(&atchan->xfers_list, ...)
if (!desc->active_xfer) <-- out-of-bounds read
list_del(&desc->xfer_node) <-- list corruption
at_xdmac_device_terminate_all() empties atchan->xfers_list and clears the
cyclic flag without clearing atchan->irq_status or stopping the scheduled
tasklet. When at_xdmac_tasklet() runs, it sees the stale
atchan->irq_status bits and computes a bogus descriptor pointer from the
empty list head, causing an out-of-bounds read and corrupting
atchan->xfers_list and atchan->free_descs_list if desc->active_xfer reads
as non-zero.
[1] https://sashiko.dev/#/bug/linux-bba900ca-f8ae-4ff8-a433-e3d7588cc938
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261115080245.910534-1-zihengw03@163.com?part=1
prev parent reply other threads:[~2026-11-15 8:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 8:02 [PATCH] dmaengine: at_xdmac: handle empty transfer list in tx_status Ziheng Wei
2026-11-15 8:19 ` 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=sashiko-outbox-215288@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
--cc=zihengw03@163.com \
/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.