Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: Frank Li <Frank.Li@nxp.com>, Vinod Koul <vkoul@kernel.org>,
	dmaengine@vger.kernel.org, imx@lists.linux.dev,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] dmaengine: fsl-edma: Fix channel leak in fsl_edma_xlate()
Date: Mon, 16 Nov 2026 14:20:06 -0600	[thread overview]
Message-ID: <avtlduHQA1_llfis@SMW015318> (raw)
In-Reply-To: <179395206206.2118334.5568431940571202082@iscas.ac.cn>

On Fri, Nov 06, 2026 at 08:01:02AM -0000, Wentao Liang wrote:
> fsl_edma_xlate() acquires a channel with dma_get_slave_channel() and only
> then validates the srcid taken from the device tree. When the srcid turns
> out to be invalid the function just returns NULL, leaving the channel
> with its client count elevated and marked private, so it can never be
> requested again.
>
> Validate the srcid before any channel is acquired: reject a zero srcid
> and a srcid that is already in use up front. With that, no channel can be
> leaked on the error path and the release added in v1 is not needed.
>
> Fixes: 6aa60f79e679 ("dmaengine: fsl-edma: add safety check for 'srcid'")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---

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


> Changes in v2:
> - Check dma_spec->args[1] before dma_get_slave_channel() instead of
>   releasing the channel on the error path, as Frank Li suggested. The
>   zero-srcid test is folded into the existing fsl_edma_srcid_in_use()
>   check, so the code stays where it is.
> - Link to v1: https://lore.kernel.org/all/20260916092733.2002700-1-vulab@iscas.ac.cn/
> - Sorry for the very late reply to this review.
>
>  drivers/dma/fsl-edma-main.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c
> index 630285c85482..e2ef18ad1a3e 100644
> --- a/drivers/dma/fsl-edma-main.c
> +++ b/drivers/dma/fsl-edma-main.c
> @@ -266,7 +266,8 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
>  		if (chan->client_count)
>  			continue;
>
> -		if (fsl_edma_srcid_in_use(fsl_edma, dma_spec->args[1]))
> +		if (!dma_spec->args[1] ||
> +		    fsl_edma_srcid_in_use(fsl_edma, dma_spec->args[1]))
>  			return NULL;
>
>  		if ((chan->chan_id / chans_per_mux) == dma_spec->args[0]) {
> @@ -275,13 +276,6 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
>  				chan->device->privatecnt++;
>  				fsl_chan = to_fsl_edma_chan(chan);
>  				fsl_chan->srcid = dma_spec->args[1];
> -
> -				if (!fsl_chan->srcid) {
> -					dev_err(&fsl_chan->pdev->dev, "Invalidate srcid %d\n",
> -						fsl_chan->srcid);
> -					return NULL;
> -				}
> -
>  				fsl_edma_chan_mux(fsl_chan, fsl_chan->srcid,
>  						true);
>  				return chan;
> --
> 2.34.1
>
>

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06  8:01 [PATCH v2] dmaengine: fsl-edma: Fix channel leak in fsl_edma_xlate() Wentao Liang
2026-11-16 20:20 ` 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=avtlduHQA1_llfis@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vkoul@kernel.org \
    --cc=vulab@iscas.ac.cn \
    /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