From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: Frank.Li@kernel.org, dmaengine@vger.kernel.org, vkoul@kernel.org
Subject: Re: [PATCHv2] dmaengine: at_hdmac: fix sparse '__iomem' cast warning in memset helpers
Date: Fri, 24 Jul 2026 23:10:13 +0000 [thread overview]
Message-ID: <20260724231013.D44771F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724225958.43925-1-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but atc_prep_dma_memset_sg() fails to broadcast the byte value into a 32-bit pattern, leading to incorrect memory fills.
- [High] This problem wasn't introduced by this patch, but there is a guaranteed kernel oops on error paths of DMA prep functions due to dereferencing an uninitialized vd->tx.chan pointer in atdma_desc_free().
--
--- Patch [1]: [PATCHv2] dmaengine: at_hdmac: fix sparse '__iomem' cast warning in memset helpers ---
commit e39a1989ac7867eaa551256bdc408f22e82b835b
Author: Rosen Penev <rosenp@gmail.com>
dmaengine: at_hdmac: fix sparse '__iomem' cast warning in memset helpers
This patch changes the type of vaddr in memset helpers to avoid sparse
warnings about casting away the __iomem address space. It also updates the
memset_vaddr field in struct at_desc to match the actual usage.
Link: https://lore.kernel.org/oe-kbuild-all/202607231110.8MqNRj0Q-lkp@intel.com/
> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index e5b30a57c477a..7c071e6496371 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
[ ... ]
> @@ -1189,7 +1189,7 @@ atc_prep_dma_memset_sg(struct dma_chan *chan,
> __func__);
> return NULL;
> }
> - *(u32*)vaddr = value;
> + *vaddr = value;
[Severity: High]
This problem wasn't introduced by this patch, but does this correctly format
the fill pattern?
If atc_prep_dma_memset_sg() is called with a non-zero byte value (e.g., 0xAA),
the hardware memset pool buffer is initialized with the unexpanded 32-bit word
(0x000000AA). Because the controller repeatedly copies this 32-bit word to the
destination buffer in 4-byte chunks, the resulting memory is filled with an
incorrect pattern.
In atc_prep_dma_memset(), the value is correctly expanded into a 32-bit
pattern before assignment. Should atc_prep_dma_memset_sg() do the same?
>
> desc = kzalloc_flex(*desc, sg, sg_len, GFP_ATOMIC);
> if (!desc)
[Severity: High]
This isn't a bug introduced by this patch, but will the error paths after this
allocation cause a NULL pointer dereference?
If a failure occurs later in this function, such as when checking buffer
alignment, the code jumps to err_free_desc and calls atdma_desc_free().
Since desc was allocated via kzalloc_flex() and vchan_tx_prep() has not yet
initialized the virtual channel structure, vd->tx.chan is NULL.
atdma_desc_free() immediately dereferences it:
atdma_desc_free()
struct at_dma *atdma = to_at_dma(vd->tx.chan->device);
Could this crash the kernel under memory pressure or when invalid scatterlists
are passed?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724225958.43925-1-rosenp@gmail.com?part=1
prev parent reply other threads:[~2026-07-24 23:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 22:59 [PATCHv2] dmaengine: at_hdmac: fix sparse '__iomem' cast warning in memset helpers Rosen Penev
2026-07-24 23:10 ` 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=20260724231013.D44771F000E9@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.