From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: vkoul@kernel.org, dmaengine@vger.kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH] dmaengine: validate dev and name in dma_request_chan()
Date: Thu, 16 Jul 2026 05:37:16 +0000 [thread overview]
Message-ID: <20260716053717.0B3F31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716052758.23465-1-phucduc.bui@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but if `kasprintf` fails to allocate `chan->name`, the function returns the channel but leaves `chan->slave` uninitialized.
--
--- Patch [1]: [PATCH] dmaengine: validate dev and name in dma_request_chan() ---
commit ac1213130dc39a9098faa262ed0755d63436e5be
Author: bui duc phuc <phucduc.bui@gmail.com>
dmaengine: validate dev and name in dma_request_chan()
This commit adds a WARN_ON check for NULL dev and name pointers at the
start of dma_request_chan(). It helps catch invalid caller arguments early
instead of causing NULL pointer dereferences later during lookup.
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
[ ... ]
> @@ -814,10 +814,15 @@ static const struct dma_slave_map *dma_filter_match(struct dma_device *device,
> */
> struct dma_chan *dma_request_chan(struct device *dev, const char *name)
> {
[ ... ]
> found:
> #ifdef CONFIG_DEBUG_FS
> chan->dbg_client_name = kasprintf(GFP_KERNEL, "%s:%s", dev_name(dev), name);
> /* No functional issue if it fails, users are supposed to test before use */
> #endif
>
> chan->name = kasprintf(GFP_KERNEL, "dma:%s", name);
> if (!chan->name)
> return chan;
> chan->slave = dev;
[Severity: High]
This isn't a bug introduced by this patch, but is it intended to return the
channel with an uninitialized slave pointer here?
If kasprintf fails under memory pressure, the function returns the channel
early:
dma_request_chan() {
...
chan->name = kasprintf(GFP_KERNEL, "dma:%s", name);
if (!chan->name)
return chan;
...
}
This leaves chan->slave uninitialized. If DMA provider drivers rely on
chan->slave pointing to the client device, could this cause a NULL pointer
dereference or memory corruption when accessed later?
If returning the channel is intended upon name allocation failure, should
chan->slave be initialized first?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260716052758.23465-1-phucduc.bui@gmail.com?part=1
prev parent reply other threads:[~2026-07-16 5:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 5:27 [PATCH] dmaengine: validate dev and name in dma_request_chan() phucduc.bui
2026-07-16 5:37 ` 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=20260716053717.0B3F31F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=phucduc.bui@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox