]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
crypto: caam - fix netdev memory leak in dpaa2_caam_probe
authorJianpeng Chang <jianpeng.chang.cn@windriver.com>
Tue, 20 Jan 2026 01:55:24 +0000 (09:55 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 31 Jan 2026 02:52:31 +0000 (10:52 +0800)
commit7d43252b3060b0ba4a192dce5dba85a3f39ffe39
treeedbd572a3f28a4f93e22402c50950f40c35eb2c4
parent6d0de6014b98c5051bb3427e97db7c62d9454f89
crypto: caam - fix netdev memory leak in dpaa2_caam_probe

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@windriver.com>
Reviewed-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg_qi2.c
drivers/crypto/caam/caamalg_qi2.h