From: sashiko-bot@kernel.org
To: "Brian Masney" <bmasney@redhat.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH] dmaengine: qcom: gpi: correct channel name in error path
Date: Thu, 25 Jun 2026 14:38:01 +0000 [thread overview]
Message-ID: <20260625143802.493EC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260625-qcom-gpi-err-fix-v1-1-5ca3f00fe2e3@redhat.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [Critical] The error path in `gpi_ch_init()` frees the event ring DMA memory without sending the required hardware deallocation command (`GPI_EV_CMD_DEALLOC`), resulting in DMA Use-After-Free.
- [High] The software state machine (`gchan->pm_state`) is not reverted when `gpi_ch_init()` fails, leading to a double-teardown hardware timeout when the client later releases the successfully allocated sibling channel.
- [High] The event processing tasklet is not killed before freeing the event ring memory in the error path of `gpi_ch_init()`, creating a Use-After-Free vulnerability.
--
commit 40116dd1267be01863d674224210915823326daa
Author: Brian Masney <bmasney@redhat.com>
dmaengine: qcom: gpi: correct channel name in error path
This commit fixes an issue where the wrong channel was passed to
gpi_send_cmd() during the error handling path of gpi_ch_init(). Correcting
this resolves command completion timeouts when hardware cleanup occurs.
> diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c
> index a5055a6273af6..3f390b5821abb 100644
> --- a/drivers/dma/qcom/gpi.c
> +++ b/drivers/dma/qcom/gpi.c
> @@ -1965,12 +1965,12 @@ static int gpi_ch_init(struct gchan *gchan)
> error_start_chan:
> for (i = i - 1; i >= 0; i--) {
> gpi_stop_chan(&gpii->gchan[i]);
> - gpi_send_cmd(gpii, gchan, GPI_CH_CMD_RESET);
> + gpi_send_cmd(gpii, &gpii->gchan[i], GPI_CH_CMD_RESET);
> }
> i = 2;
> error_alloc_chan:
> for (i = i - 1; i >= 0; i--)
> - gpi_reset_chan(gchan, GPI_CH_CMD_DE_ALLOC);
> + gpi_reset_chan(&gpii->gchan[i], GPI_CH_CMD_DE_ALLOC);
[Severity: High]
This is a pre-existing issue, but could this error path leave the software
pm_state in an incorrect state?
If gpi_ch_init() fails, the hardware channels are deallocated, but their
pm_state remains as ACTIVE_STATE or CONFIG_STATE. When the client handles the
failure by releasing the previously successful sibling channel via
gpi_free_chan_resources(), it reads the stale state:
drivers/dma/qcom/gpi.c:gpi_free_chan_resources() {
...
if (cur_state == ACTIVE_STATE) {
gpi_stop_chan(gchan);
ret = gpi_send_cmd(gpii, gchan, GPI_CH_CMD_RESET);
...
}
Would this cause the driver to attempt a graceful shutdown on a channel that
has already been deallocated in hardware, resulting in the same completion
timeouts this patch aims to fix?
> error_alloc_ev_ring:
> gpi_disable_interrupts(gpii);
> error_config_int:
[Severity: High]
This is a pre-existing issue, but should the event processing tasklet be
canceled in this error path?
gpi_config_interrupts() registers the IRQ, which can fire and schedule
gpii->ev_task. If initialization fails here, gpi_disable_interrupts() frees
the IRQ but does not wait for or cancel scheduled tasklets.
Could this allow the asynchronous tasklet to execute against the freed ev_ring
memory when gpi_process_events() runs?
[Severity: Critical]
This is a pre-existing issue, but is the event ring DMA memory freed without
sending the GPI_EV_CMD_DEALLOC command to the hardware?
Just below this in gpi_ch_init(), gpi_free_ring(&gpii->ev_ring, gpii) is
called. If the hardware retains the physical address of the event ring after
the driver has freed its backing DMA memory, could it silently write into
freed memory if an event is generated later, causing DMA memory corruption?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260625-qcom-gpi-err-fix-v1-1-5ca3f00fe2e3@redhat.com?part=1
next prev parent reply other threads:[~2026-06-25 14:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 14:21 [PATCH] dmaengine: qcom: gpi: correct channel name in error path Brian Masney
2026-06-25 14:38 ` sashiko-bot [this message]
2026-06-25 15:01 ` 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=20260625143802.493EC1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=bmasney@redhat.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 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.