Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] selftests/net: fix EVP_MD_CTX leak in tcp_mmap
@ 2026-07-02  2:59 Wang Yan
  2026-07-09  8:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Yan @ 2026-07-02  2:59 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, shuah
  Cc: horms, lixiaoyan, netdev, linux-kselftest, linux-kernel, Wang Yan

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.

Fixes: 5c5945dc695c ("selftests/net: Add SHA256 computation over data sent in tcp_mmap")
Signed-off-by: Wang Yan <wangyan01@kylinos.cn>
---
 tools/testing/selftests/net/tcp_mmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
index 4fcce5150850..2544ae35d07a 100644
--- a/tools/testing/selftests/net/tcp_mmap.c
+++ b/tools/testing/selftests/net/tcp_mmap.c
@@ -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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftests/net: fix EVP_MD_CTX leak in tcp_mmap
  2026-07-02  2:59 [PATCH] selftests/net: fix EVP_MD_CTX leak in tcp_mmap Wang Yan
@ 2026-07-09  8:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-09  8:40 UTC (permalink / raw)
  To: Wang Yan
  Cc: davem, edumazet, kuba, pabeni, shuah, horms, lixiaoyan, netdev,
	linux-kselftest, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Thu,  2 Jul 2026 10:59:49 +0800 you wrote:
> 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.
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-09  8:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02  2:59 [PATCH] selftests/net: fix EVP_MD_CTX leak in tcp_mmap Wang Yan
2026-07-09  8:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox