From: Frank Li <Frank.li@oss.nxp.com>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
Kees Cook <kees@kernel.org>, Peng Ma <peng.ma@nxp.com>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] dmaengine: fsl-dpaa2-qdma: fix ppriv memory leaks
Date: Mon, 21 Sep 2026 10:45:25 -0500 [thread overview]
Message-ID: <arFRFXaWdVKyMyDg@SMW015318> (raw)
In-Reply-To: <20260921111424.378477-1-lgs201920130244@gmail.com>
On Mon, Sep 21, 2026 at 07:14:24PM +0800, Guangshuo Li wrote:
> dpaa2_qdma_setup() allocates priv->ppriv, but failures after the
> allocation can return from the function without releasing it. The
> existing probe cleanup for priv->ppriv is only reached when a later
> initialization step fails.
>
> The normal remove path does not release priv->ppriv either, causing the
> allocation to be leaked when the driver is unbound.
>
> Since dpaa2_qdma_setup() is only called from probe, allocate priv->ppriv
> with devm_kcalloc(). This automatically releases the memory on probe
> failure and driver removal. Remove the now redundant manual cleanup from
> the probe error path.
>
> Fixes: 7fdf9b05c73b ("dmaengine: fsl-dpaa2-qdma: Add NXP dpaa2 qDMA controller driver for Layerscape SoCs")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> v2:
> - Use devm_kcalloc() for priv->ppriv, as suggested by Frank Li.
> - Remove the now redundant manual cleanup from the probe error path.
> drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
> index bf771251264d..d6843da29122 100644
> --- a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
> +++ b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
> @@ -353,7 +353,8 @@ static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev)
> }
>
> priv->num_pairs = min(priv->dpdmai_attr.num_of_priorities, prio_def);
> - ppriv = kzalloc_objs(*ppriv, priv->num_pairs);
> + ppriv = devm_kcalloc(dev, priv->num_pairs, sizeof(*ppriv),
> + GFP_KERNEL);
> if (!ppriv) {
> err = -ENOMEM;
> goto exit;
> @@ -757,7 +758,6 @@ static int dpaa2_qdma_probe(struct fsl_mc_device *dpdmai_dev)
> dpaa2_dpmai_store_free(priv);
> dpaa2_dpdmai_dpio_free(priv);
> err_dpio_setup:
> - kfree(priv->ppriv);
> dpdmai_close(priv->mc_io, 0, dpdmai_dev->mc_handle);
> err_dpdmai_setup:
> fsl_mc_portal_free(priv->mc_io);
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-09-21 15:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 11:14 [PATCH v2] dmaengine: fsl-dpaa2-qdma: fix ppriv memory leaks Guangshuo Li
2026-09-21 15:45 ` Frank Li [this message]
2026-09-21 22:05 ` Krzysztof Kozlowski
2026-09-22 2:11 ` Guangshuo 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=arFRFXaWdVKyMyDg@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=kees@kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.ma@nxp.com \
--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 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.