]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: harness: fix pidfd leak in __wait_for_test
authorGeliang Tang <tanggeliang@kylinos.cn>
Mon, 20 Apr 2026 09:45:28 +0000 (17:45 +0800)
committerChristian Brauner <brauner@kernel.org>
Thu, 21 May 2026 11:44:15 +0000 (13:44 +0200)
Fix the pidfd leak in kselftest_harness.h's __wait_for_test() where
childfd = syscall(__NR_pidfd_open, t->pid, 0) is never closed.

Fixes: 73a3cde97677 ("selftests: harness: Implement test timeouts through pidfd")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Link: https://patch.msgid.link/a82e275ccfb2609a1984d90ab559fa3af78f1e81.1776678050.git.tanggeliang@kylinos.cn
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
tools/testing/selftests/kselftest_harness.h

index cfdce9cd252e75b8bc0691d3d62701fff2f1ff06..261e4df94d9d5b7e21601f577ddf720e7b0077cd 100644 (file)
@@ -996,6 +996,7 @@ static void __wait_for_test(struct __test_metadata *t)
        poll_child.fd = childfd;
        poll_child.events = POLLIN;
        ret = poll(&poll_child, 1, t->timeout * 1000);
+       close(childfd);
        if (ret == -1) {
                t->exit_code = KSFT_FAIL;
                fprintf(TH_LOG_STREAM,