[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4h7joiwvamq3sgrkhyemtug4lucyicnx7beuik3i5foydwb256@iemjvkrs7h2d>
Date: Fri, 16 Jan 2026 01:46:17 -0800
From: Breno Leitao <leitao@...ian.org>
To: Jianpeng Chang <jianpeng.chang.cn@...driver.com>
Cc: horia.geanta@....com, pankaj.gupta@....com, gaurav.jain@....com,
herbert@...dor.apana.org.au, davem@...emloft.net, kuba@...nel.org,
linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] crypto: caam: fix netdev memory leak in dpaa2_caam_probe
On Fri, Jan 16, 2026 at 09:44:55AM +0800, Jianpeng Chang wrote:
> When commit 0e1a4d427f58 ("crypto: caam: Unembed net_dev structure in
> dpaa2") converted embedded net_device to dynamically allocated pointers,
> it added cleanup in dpaa2_dpseci_disable() but missed adding cleanup in
> dpaa2_dpseci_free() for error paths.
>
> This causes memory leaks when dpaa2_dpseci_dpio_setup() fails during probe
> due to DPIO devices not being ready yet. The kernel's deferred probe
> mechanism handles the retry successfully, but the netdevs allocated during
> the failed probe attempt are never freed, resulting in kmemleak reports
> showing multiple leaked netdev-related allocations all traced back to
> dpaa2_caam_probe().
>
> Fix this by preserving the CPU mask of allocated netdevs during setup and
> using it for cleanup in dpaa2_dpseci_free(). This approach ensures that
> only the CPUs that actually had netdevs allocated will be cleaned up,
> avoiding potential issues with CPU hotplug scenarios.
>
> Fixes: 0e1a4d427f58 ("crypto: caam: Unembed net_dev structure in dpaa2")
> Signed-off-by: Jianpeng Chang <jianpeng.chang.cn@...driver.com>
> ---
> drivers/crypto/caam/caamalg_qi2.c | 31 ++++++++++++++++---------------
> drivers/crypto/caam/caamalg_qi2.h | 2 ++
> 2 files changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c
> index 107ccb2ade42..a66c62174a0f 100644
> --- a/drivers/crypto/caam/caamalg_qi2.c
> +++ b/drivers/crypto/caam/caamalg_qi2.c
> @@ -4810,6 +4810,17 @@ static void dpaa2_dpseci_congestion_free(struct dpaa2_caam_priv *priv)
> kfree(priv->cscn_mem);
> }
>
> +static void free_dpaa2_pcpu_netdev(struct dpaa2_caam_priv *priv, const cpumask_t *cpus)
> +{
> + struct dpaa2_caam_priv_per_cpu *ppriv;
> + int i;
> +
> + for_each_cpu(i, cpus) {
> + ppriv = per_cpu_ptr(priv->ppriv, i);
> + free_netdev(ppriv->net_dev);
> + }
> +}
Why is the function being moved here? Please keep code movement separate
from functional changes, or at minimum explain why the move is necessary
in the commit message.
Powered by blists - more mailing lists