mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Lee Jones <lee@kernel.org>
Cc: Paul Cercueil <paul@crapouillou.net>,
	Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
	Alex Smith <alex@alex-smith.me.uk>,
	Colin Ian King <colin.i.king@gmail.com>,
	linux-mips@vger.kernel.org, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 10/11] dmaengine: jz4780: Fix descriptor cleanup on hwdesc setup failure
Date: Tue, 17 Nov 2026 14:50:33 -0500	[thread overview]
Message-ID: <avywCU5k0B_AnlWR@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20261117163809.622249-11-lee@kernel.org>

On Tue, Nov 17, 2026 at 04:37:11PM +0000, Lee Jones wrote:
> When jz4780_dma_setup_hwdesc() fails in jz4780_dma_prep_slave_sg() or
> jz4780_dma_prep_dma_cyclic(), the error paths pass &jzchan->desc->vdesc
> to jz4780_dma_desc_free() instead of the newly allocated &desc->vdesc.
> This leaks the newly allocated descriptor and either dereferences NULL
> when jzchan->desc is NULL or frees the currently active descriptor while
> it is still in flight.  Furthermore, jz4780_dma_desc_free() derives
> jzchan from vdesc->tx.chan, which is not yet initialised before
> vchan_tx_prep() is called.
>
> Initialise desc->vdesc.tx.chan in jz4780_dma_desc_alloc() and pass
> &desc->vdesc to jz4780_dma_desc_free() in the preparation error paths.
>
> Fixes: fc878efe84c3 ("dmaengine: jz4780: fix resource leaks on error exit return")
> Closes: https://sashiko.dev/#/bug/linux-b39121ef-5ffb-401a-9d04-0afccd467bde
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>


>
> v1 => v2: Correct the Fixes: tag to fc878efe84c3
>
>  drivers/dma/dma-jz4780.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
> index ac2094e65ecf..c3974c825ba7 100644
> --- a/drivers/dma/dma-jz4780.c
> +++ b/drivers/dma/dma-jz4780.c
> @@ -248,6 +248,7 @@ jz4780_dma_desc_alloc(struct jz4780_dma_chan *jzchan, unsigned int count,
>  		return NULL;
>  	}
>
> +	desc->vdesc.tx.chan = &jzchan->vchan.chan;
>  	desc->count = count;
>  	desc->type = type;
>
> @@ -379,7 +380,7 @@ static struct dma_async_tx_descriptor *jz4780_dma_prep_slave_sg(
>  					      sg_dma_len(&sgl[i]),
>  					      direction);
>  		if (err < 0) {
> -			jz4780_dma_desc_free(&jzchan->desc->vdesc);
> +			jz4780_dma_desc_free(&desc->vdesc);
>  			return NULL;
>  		}
>
> @@ -426,7 +427,7 @@ static struct dma_async_tx_descriptor *jz4780_dma_prep_dma_cyclic(
>  		err = jz4780_dma_setup_hwdesc(jzchan, &desc->desc[i], buf_addr,
>  					      period_len, direction);
>  		if (err < 0) {
> -			jz4780_dma_desc_free(&jzchan->desc->vdesc);
> +			jz4780_dma_desc_free(&desc->vdesc);
>  			return NULL;
>  		}
>
> --
> 2.56.0.679.gc527c65306-goog
>

  reply	other threads:[~2026-11-17 19:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 16:37 [PATCH v2 00/11] dmaengine: Fix teardown races, resource leaks, and error handling Lee Jones
2026-11-17 16:37 ` [PATCH v2 01/11] dmaengine: pl08x: Defer OF DMA controller registration until slave setup Lee Jones
2026-11-17 18:44   ` Linus Walleij
2026-11-17 19:37   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 02/11] dmaengine: ae4dma: Let the pending work exit before cancelling it Lee Jones
2026-11-17 19:38   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 03/11] dmaengine: ae4dma: Unregister DMA engine in ae4_pci_remove() Lee Jones
2026-11-17 19:40   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 04/11] dmaengine: ptdma: Unmap descriptor in pt_do_cleanup() Lee Jones
2026-11-17 19:41   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 05/11] dmaengine: ptdma: Remove completed descriptor under vc.lock in pt_cmd_callback_work() Lee Jones
2026-11-17 19:42   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 06/11] dmaengine: amlogic: Destroy free_wq after devres DMA device unregistration Lee Jones
2026-11-17 19:43   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 07/11] dmaengine: arm-dma350: Query dma_cookie_status() under vc.lock in d350_tx_status() Lee Jones
2026-11-17 19:44   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 08/11] dmaengine: bestcomm: Defer publishing bcom_eng until initialisation completes Lee Jones
2026-11-17 19:48   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 09/11] dmaengine: bestcomm: Check rh_create() return value in bcom_sram_init() Lee Jones
2026-11-17 19:49   ` Frank Li
2026-11-17 16:37 ` [PATCH v2 10/11] dmaengine: jz4780: Fix descriptor cleanup on hwdesc setup failure Lee Jones
2026-11-17 19:50   ` Frank Li [this message]
2026-11-17 19:54   ` Paul Cercueil
2026-11-17 16:37 ` [PATCH v2 11/11] dmaengine: dmatest: Avoid unsigned underflow in min_odd() Lee Jones
2026-11-17 19:51   ` 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=avywCU5k0B_AnlWR@lizhi-Precision-Tower-5810 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=alex@alex-smith.me.uk \
    --cc=colin.i.king@gmail.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®