selftests/net: fix EVP_MD_CTX leak in tcp_mmap
Subsystems (3)
PATCH 1/1 selftests/net: fix EVP_MD_CTX leak in tcp_mmap
In tcp_mmap.c, both child_thread() and main() allocate an EVP_MD_CTX via EVP_MD_CTX_new() when integrity checking is enabled, but neither function releases the context. child_thread() misses the free in its common cleanup block, and main() returns without freeing the context.
This results in a SHA256 context leak on every run that uses the ‑i (integrity) option. Add the missing EVP_MD_CTX_free() calls to the appropriate cleanup paths to fix the leak.
--- tools/testing/selftests/net/tcp_mmap.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/net/tcp_mmap.c +4 -0
@@ -313,6 +313,8 @@ void *child_thread(void *arg) tcp_info_get_rcv_mss(fd)); } error: +if (ctx) +EVP_MD_CTX_free (ctx);munmap (buffer, buffer_sz);close (fd);if (zflg)
@@ -606,6 +608,8 @@ int main(int argc, char *argv[])EVP_DigestFinal_ex (ctx, digest, &digest_len);send (fd, digest, (size_t )SHA256_DIGEST_LENGTH ,0 ); } +if (ctx) +EVP_MD_CTX_free (ctx);close (fd);munmap (buffer, buffer_sz);return 0 ;
Signature · 1 line
2.25.1
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Thu, 2 Jul 2026 10:59:49 +0800 you wrote:
In
tcp_mmap.c, bothchild_thread()andmain()allocate anEVP_MD_CTXviaEVP_MD_CTX_new()when integrity checking is enabled, but neither function releases the context.child_thread()misses the free in its common cleanup block, andmain()returns without freeing the context.This results in a SHA256 context leak on every run that uses the ‑i (integrity) option. Add the missing
EVP_MD_CTX_free()calls to the appropriate cleanup paths to fix the leak.[...]
Here is the summary with links:
- selftests/net: fix EVP_MD_CTX leak in tcp_mmap
https://git.kernel.org/netdev/net/c/f4ef35efbb49
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html