From: sashiko-bot@kernel.org
To: "Golla Nagendra" <nagendra.golla@amd.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH 1/6] dmaengine: zynqmp_dma: Fix alloc_chan_resources error cleanup
Date: Thu, 06 Aug 2026 12:48:24 +0000 [thread overview]
Message-ID: <20260806124825.014A81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806123014.2120447-2-nagendra.golla@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Stale list iteration pointers after dropping and reacquiring the lock in zynqmp_dma_chan_desc_cleanup.
--
--- Patch [1]: [PATCH 1/6] dmaengine: zynqmp_dma: Fix alloc_chan_resources error cleanup ---
commit 8086a707a0f2604d248437e0453b7591161223d9
Author: Golla Nagendra <nagendra.golla@amd.com>
dmaengine: zynqmp_dma: Fix alloc_chan_resources error cleanup
Channel resource allocation can fail after runtime PM has been acquired
and after part of the descriptor state has been initialized. Without
proper rollback, the error path leaks a runtime PM reference and, on
coherent allocation failure, also leaks the software descriptor pool.
> diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
> index f6a812e49ddca..b7c5612806948 100644
> --- a/drivers/dma/xilinx/zynqmp_dma.c
> +++ b/drivers/dma/xilinx/zynqmp_dma.c
[ ... ]
> @@ -516,6 +520,13 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan)
> }
>
> return ZYNQMP_DMA_NUM_DESCS;
> +
> +err_free_sw_desc_pool:
> + kfree(chan->sw_desc_pool);
> + chan->sw_desc_pool = NULL;
> +err_pm:
> + pm_runtime_put_autosuspend(chan->dev);
> + return ret;
> }
[Severity: High]
This isn't a bug introduced by this patch, but looking at
zynqmp_dma_chan_desc_cleanup() in drivers/dma/xilinx/zynqmp_dma.c,
can dropping the lock during iteration lead to list corruption?
drivers/dma/xilinx/zynqmp_dma.c:zynqmp_dma_chan_desc_cleanup() {
...
list_for_each_entry_safe(desc, next, &chan->done_list, node) {
...
if (dmaengine_desc_callback_valid(&cb)) {
spin_unlock_irqrestore(&chan->lock, irqflags);
dmaengine_desc_callback_invoke(&cb, NULL);
spin_lock_irqsave(&chan->lock, irqflags);
}
...
}
If a DMA client invokes dmaengine_terminate_all() from the callback,
zynqmp_dma_device_terminate_all() will acquire the lock and move all pending
and done descriptors (including the cached next pointer) to chan->free_list.
When the callback returns and the lock is reacquired, would the loop iterator
operate on nodes linked in the free_list instead of done_list?
Since the loop condition checks against &chan->done_list, could this iterate
past the end of the list and trigger an out-of-bounds dereference?
Additionally, would calling zynqmp_dma_free_descriptor() again on a descriptor
already moved to free_list cause desc_free_cnt to exceed its maximum limit
and corrupt the allocator state?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806123014.2120447-1-nagendra.golla@amd.com?part=1
next prev parent reply other threads:[~2026-08-06 12:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 12:30 [PATCH 0/6] dmaengine: zynqmp_dma: Fix error paths and follow-up cleanups Golla Nagendra
2026-08-06 12:30 ` [PATCH 1/6] dmaengine: zynqmp_dma: Fix alloc_chan_resources error cleanup Golla Nagendra
2026-08-06 12:48 ` sashiko-bot [this message]
2026-08-06 15:39 ` Frank Li
2026-08-06 12:30 ` [PATCH 2/6] dmaengine: zynqmp_dma: Fix chan probe error handling Golla Nagendra
2026-08-06 12:51 ` sashiko-bot
2026-08-06 15:48 ` Frank Li
2026-08-06 12:30 ` [PATCH 3/6] dmaengine: zynqmp_dma: Fix stale kerneldoc comments Golla Nagendra
2026-08-06 12:42 ` sashiko-bot
2026-08-06 15:49 ` Frank Li
2026-08-06 12:30 ` [PATCH 4/6] dmaengine: zynqmp_dma: Fix minor whitespace Golla Nagendra
2026-08-06 12:41 ` sashiko-bot
2026-08-06 15:53 ` Frank Li
2026-08-06 12:30 ` [PATCH 5/6] dmaengine: zynqmp_dma: Reject zero-length memcpy transfers Golla Nagendra
2026-08-06 12:44 ` sashiko-bot
2026-08-06 15:56 ` Frank Li
2026-08-07 11:02 ` Golla, Nagendra
2026-08-06 12:30 ` [PATCH 6/6] dmaengine: zynqmp_dma: Remove unused define and duplicate IRQ bit Golla Nagendra
2026-08-06 16:00 ` Frank Li
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=20260806124825.014A81F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=nagendra.golla@amd.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