From: sashiko-bot@kernel.org
To: "Nuno Sá" <nuno.sa@analog.com>
Cc: dmaengine@vger.kernel.org, Frank.Li@kernel.org, vkoul@kernel.org
Subject: Re: [PATCH v5 2/9] dmaengine: dma-axi-dmac: Use bus width capability helpers
Date: Fri, 09 Oct 2026 16:03:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-165812@kernel.org> (raw)
In-Reply-To: <20261009-dmaengine-support-wider-dma-masks-v5-2-4c4e63a7a1af@analog.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] dmaengine: axi-dmac: Incorrect copy_align assignment causes UB for >= 32-byte widths
--
commit 32d178f66f02ed239c1f773e106395cd1e81ae9c
Author: Nuno Sá <nuno.sa@analog.com>
Subject: dmaengine: dma-axi-dmac: Use bus width capability helpers
This commit transitions the AXI DMA controller driver to use dma_bus_width_set()
to advertise source and destination bus widths. This allows the driver to express
widths of 32 bytes and above while maintaining legacy fields.
> diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
> index d47ff27e1408f..ca9cf1e0c5e46 100644
> --- a/drivers/dma/dma-axi-dmac.c
> +++ b/drivers/dma/dma-axi-dmac.c
[ ... ]
> @@ -1262,8 +1262,13 @@ static int axi_dmac_probe(struct platform_device *pdev)
> dma_dev->device_terminate_all = axi_dmac_terminate_all;
> dma_dev->device_synchronize = axi_dmac_synchronize;
> dma_dev->dev = &pdev->dev;
> - dma_dev->src_addr_widths = BIT(dmac->chan.src_width);
> - dma_dev->dst_addr_widths = BIT(dmac->chan.dest_width);
> + ret = dma_bus_width_set(dma_dev->src_bus_widths, dmac->chan.src_width);
> + if (ret)
> + return ret;
> +
> + ret = dma_bus_width_set(dma_dev->dst_bus_widths, dmac->chan.dest_width);
[Severity: High]
Does this migration to support widths of 32 bytes and above expose an
undefined behavior in the alignment checks?
Later in axi_dmac_probe(), the copy alignment is assigned the literal byte
width:
dma_dev->copy_align = (dmac->chan.address_align_mask + 1);
However, dma_dev->copy_align expects a log2 alignment exponent (as defined
by enum dmaengine_alignment). The DMA core uses dmaengine_check_align(),
which calculates the alignment using a bitwise shift:
include/linux/dmaengine.h:dmaengine_check_align() {
...
return !(((1 << align) - 1) & (off1 | off2 | len));
}
With this patch explicitly allowing widths of 32 bytes and above,
copy_align can now reach 32. This results in an operation of 1 << 32,
which triggers undefined behavior on 32-bit arithmetic, potentially
invalidating DMA transfer alignment checks.
> + if (ret)
> + return ret;
> dma_dev->directions = BIT(dmac->chan.direction);
> dma_dev->residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
> dma_dev->max_sg_burst = 31; /* 31 SGs maximum in one burst */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009-dmaengine-support-wider-dma-masks-v5-0-4c4e63a7a1af@analog.com?part=2
next prev parent reply other threads:[~2026-10-09 16:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 15:52 [PATCH v5 0/9] dmaengine: Support bus widths of 32 bytes and above Nuno Sá
2026-10-09 15:52 ` [PATCH v5 1/9] " Nuno Sá
2026-10-09 19:33 ` Frank Li
2026-10-12 10:33 ` Nuno Sá
2026-10-10 2:45 ` Frank Li
2026-10-12 10:47 ` Nuno Sá
2026-10-12 14:46 ` Frank Li
2026-10-09 15:52 ` [PATCH v5 2/9] dmaengine: dma-axi-dmac: Use bus width capability helpers Nuno Sá
2026-10-09 16:03 ` sashiko-bot [this message]
2026-10-09 15:52 ` [PATCH v5 3/9] dmaengine: dw-axi-dmac: " Nuno Sá
2026-10-09 15:52 ` [PATCH v5 4/9] dmaengine: qcom: gpi: " Nuno Sá
2026-10-09 15:52 ` [PATCH v5 5/9] dmaengine: stm32-dma3: " Nuno Sá
2026-10-09 15:52 ` [PATCH v5 6/9] iio: buffer-dmaengine: Use dma_slave_caps bus width accessors Nuno Sá
2026-10-09 15:52 ` [PATCH v5 7/9] ALSA: pcm_dmaengine: Use dma_slave_caps bus width helpers Nuno Sá
2026-10-09 15:53 ` [PATCH v5 8/9] spi: dw: " Nuno Sá
2026-10-09 15:53 ` [PATCH v5 9/9] dmaengine: Drop legacy bus width fields from dma_slave_caps Nuno Sá
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-165812@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=nuno.sa@analog.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