From: Frank Li <Frank.li@oss.nxp.com>
To: Olivier Louvignes <olivier@mgcrea.io>
Cc: Vinod Koul <vkoul@kernel.org>,
Paul Cercueil <paul@crapouillou.net>,
Frank Li <Frank.Li@kernel.org>,
dmaengine@vger.kernel.org, linux-mips@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] dmaengine: dma-jz4780: Fix NULL dereference in tx_status after terminate
Date: Mon, 26 Oct 2026 15:49:48 -0500 [thread overview]
Message-ID: <at-87AHdnoWz5M9Y@SMW015318> (raw)
In-Reply-To: <20261023080953.16963-1-olivier@mgcrea.io>
On Fri, Oct 23, 2026 at 10:09:53AM +0200, Olivier Louvignes wrote:
> [You don't often get email from olivier@mgcrea.io. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> jz4780_dma_terminate_all() sets jzchan->desc to NULL. The cookie of a
> cyclic transfer never completes, so a later jz4780_dma_tx_status() call
> with that cookie finds no descriptor on the channel's lists, takes the
> else branch and reads jzchan->desc->vdesc.tx.cookie through the NULL
> pointer.
>
> The driver has always allowed this, but it only shows once something
> calls tx_status() on a terminated cyclic channel, as
> snd_dmaengine_pcm_sync_stop() does since commit 88e98af9f4b5 ("ALSA:
> pcm_dmaengine: Don't synchronize DMA channel when DMA is paused").
> Closing a playback stream then oopses:
>
> epc : jz4780_dma_tx_status+0x184/0x210
> Call Trace:
> [<8048e104>] jz4780_dma_tx_status+0x184/0x210
> [<805804d8>] snd_dmaengine_pcm_sync_stop+0x4c/0x94
> [<8058f068>] snd_soc_pcm_component_sync_stop+0x80/0xc0
> [<805775b8>] do_hw_free+0x20/0x6c
> [<80577650>] snd_pcm_release_substream+0x4c/0x9c
> [<805781ac>] snd_pcm_release+0x48/0x9c
>
> Only compare the cookie with the current descriptor's when there is one.
>
> Fixes: d894fc6046fe ("dmaengine: jz4780: add driver for the Ingenic JZ4780 DMA controller")
> Cc: stable@vger.kernel.org
> Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Apologies to the stable list: two copies of this patch reached it earlier
> today from test sends, with the Cc trailer still in place. Please ignore
> those. This is the real submission, and it is the same patch.
Please bump version when send this one.
Frank
>
> Seen on an Ingenic X1600 (HiBy R1, compatible "ingenic,x1830-dma" as
> fallback) on v7.3; the code is shared by all the SoCs this driver
> supports. The patch is build-tested on 734bef548a96 (v7.3-7363).
>
> drivers/dma/dma-jz4780.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
> index 6070dfdb7114..7f827be502f1 100644
> --- a/drivers/dma/dma-jz4780.c
> +++ b/drivers/dma/dma-jz4780.c
> @@ -658,7 +658,7 @@ static enum dma_status jz4780_dma_tx_status(struct dma_chan *chan,
> /* On the issued list, so hasn't been processed yet */
> residue = jz4780_dma_desc_residue(jzchan,
> to_jz4780_dma_desc(vdesc), 0);
> - } else if (cookie == jzchan->desc->vdesc.tx.cookie) {
> + } else if (jzchan->desc && cookie == jzchan->desc->vdesc.tx.cookie) {
> residue = jz4780_dma_desc_residue(jzchan, jzchan->desc,
> jzchan->curr_hwdesc + 1);
> }
>
> base-commit: 734bef548a96e8774d6eef5dfa2026c6edc4e80b
> --
> 2.39.5
>
prev parent reply other threads:[~2026-10-26 20:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 8:09 [PATCH] dmaengine: dma-jz4780: Fix NULL dereference in tx_status after terminate Olivier Louvignes
2026-10-25 21:58 ` Paul Cercueil
2026-10-26 20:49 ` Frank Li [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=at-87AHdnoWz5M9Y@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=olivier@mgcrea.io \
--cc=paul@crapouillou.net \
--cc=stable@vger.kernel.org \
--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