DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Amita Mishra" <amitamishra@google.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH] dmaengine: dmatest: terminate channel on timeout or error
Date: Wed, 18 Nov 2026 10:16:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-220671@kernel.org> (raw)
In-Reply-To: <20261118100839.3090172-1-amitamishra@google.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: dmatest: integer underflow in min_odd() [1]
--

commit 15e7b971cd84dccd06d2762018cf300f9236dc53
Author: Amita Mishra <amitamishra@google.com>

dmaengine: dmatest: terminate channel on timeout or error

This commit calls dmaengine_terminate_sync() before unmapping DMA buffers
when a transfer times out or completes with an error in dmatest_func().

> diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
> index 2ae3469397f37..950b7a9e77695 100644
> --- a/drivers/dma/dmatest.c
> +++ b/drivers/dma/dmatest.c
> @@ -852,6 +852,8 @@ static int dmatest_func(void *data)
>  		}
>  
>  		if (!done->done) {
> +			if (!params->polled)
> +				dmaengine_terminate_sync(chan);
>  			result("test timed out", total_tests, src->off, dst->off,
>  			       len, 0);
>  			goto error_unmap_continue;
> @@ -859,6 +861,7 @@ static int dmatest_func(void *data)
>  			   !(dma_has_cap(DMA_COMPLETION_NO_ORDER,
>  					 dev->cap_mask) &&
>  			     status == DMA_OUT_OF_ORDER)) {
> +			dmaengine_terminate_sync(chan);
>  			result(status == DMA_ERROR ?
>  			       "completion error status" :
>  			       "completion busy status", total_tests, src->off,

[Severity: High]
This problem wasn't introduced by this patch, but can min_odd() underflow
when computing src->cnt earlier in dmatest_func() [1]?

drivers/dma/dmatest.c:min_odd() {
	unsigned int val = min(x, y);

	return val % 2 ? val : val - 1;
}

When a DMA device reports max_xor or max_pq as 0 (or xor_sources /
pq_sources is 0), val is 0 and min_odd() returns UINT_MAX.  That bypasses
the (src->cnt + dst->cnt) >= 255 check by wrapping around, after which
dmatest_alloc_test_data() passes d->cnt + 1 == 0 to kcalloc() and
dereferences ZERO_SIZE_PTR when writing d->raw[0].

[1] https://sashiko.dev/#/bug/linux-ca967586-4fc1-47a3-8616-4a9d21fe7455

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118100839.3090172-1-amitamishra@google.com?part=1

      reply	other threads:[~2026-11-18 10:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 10:08 [PATCH] dmaengine: dmatest: terminate channel on timeout or error Amita Mishra
2026-11-18 10:16 ` 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-220671@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=amitamishra@google.com \
    --cc=dmaengine@vger.kernel.org \
    --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