mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
Cc: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	dmaengine@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] dmaengine: imx-sdma: Fix potential memory leak on channel zero failure
Date: Fri, 20 Nov 2026 12:08:20 -0600	[thread overview]
Message-ID: <awCMlD0Ngktbf5yk@SMW015318> (raw)
In-Reply-To: <20261120173507.3923720-1-liguangshuo@mail.sdu.edu.cn>

On Sat, Nov 21, 2026 at 01:35:05AM +0800, Guangshuo Li wrote:
> If allocating the channel zero descriptor fails, sdma_init() disables
> the clocks without releasing the already allocated channel control and
> context storage. Free that storage with the matching allocator before
> returning the error.
>
> This issue was found by our static analysis tool under development.
>
> Fixes: 1ec1e82f2510 ("dmaengine: Add Freescale i.MX SDMA support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
> ---

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

>  drivers/dma/imx-sdma.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> index 36368835a845..9c0087b3b805 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -2161,7 +2161,7 @@ static int sdma_init(struct sdma_engine *sdma)
>
>  	ret = sdma_request_channel0(sdma);
>  	if (ret)
> -		goto err_dma_alloc;
> +		goto free_channel_control;
>
>  	sdma_config_ownership(&sdma->channel[0], false, true, false);
>
> @@ -2184,6 +2184,13 @@ static int sdma_init(struct sdma_engine *sdma)
>
>  	return 0;
>
> +free_channel_control:
> +	if (sdma->iram_pool)
> +		gen_pool_free(sdma->iram_pool,
> +			      (unsigned long)sdma->channel_control, ccbsize);
> +	else
> +		dma_free_coherent(sdma->dev, ccbsize, sdma->channel_control,
> +				  ccb_phys);
>  err_dma_alloc:
>  	clk_disable(sdma->clk_ahb);
>  disable_clk_ipg:
>
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> --
> 2.43.0
>

      reply	other threads:[~2026-11-20 18:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 17:35 Guangshuo Li
2026-11-20 18:08 ` 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=awCMlD0Ngktbf5yk@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=liguangshuo@mail.sdu.edu.cn \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --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®