]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/net: fix EVP_MD_CTX leak in tcp_mmap
authorWang Yan <wangyan01@kylinos.cn>
Thu, 2 Jul 2026 02:59:49 +0000 (10:59 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 9 Jul 2026 08:32:58 +0000 (10:32 +0200)
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>
Link: https://patch.msgid.link/20260702025949.442523-1-wangyan01@kylinos.cn
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
tools/testing/selftests/net/tcp_mmap.c

index 4fcce5150850dd38739ca15272d1f307b9f29cba..2544ae35d07a839a3a503c0bb58a084b3527bdf7 100644 (file)
@@ -313,6 +313,8 @@ end:
                                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;