[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aX1wTpxIAy2kSdpi@gondor.apana.org.au>
Date: Sat, 31 Jan 2026 11:00:30 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Jianpeng Chang <jianpeng.chang.cn@...driver.com>
Cc: horia.geanta@....com, pankaj.gupta@....com, gaurav.jain@....com,
davem@...emloft.net, leitao@...ian.org, kuba@...nel.org,
linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [v2 PATCH 1/1] crypto: caam: fix netdev memory leak in
dpaa2_caam_probe
On Tue, Jan 20, 2026 at 09:55:24AM +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>
> ---
> v2:
> - fix the build error with CPUMASK_OFFSTACK disabled
> - instead of the movement of free_dpaa2_pcpu_netdev, implement it
> directly in dpaa2_dpseci_free
> v1: https://lore.kernel.org/all/20260116014455.2575351-1-jianpeng.chang.cn@windriver.com/
>
> drivers/crypto/caam/caamalg_qi2.c | 27 +++++++++++++++------------
> drivers/crypto/caam/caamalg_qi2.h | 2 ++
> 2 files changed, 17 insertions(+), 12 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists