[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250114033456.62179-1-liuye@kylinos.cn>
Date: Tue, 14 Jan 2025 11:34:56 +0800
From: liuye <liuye@...inos.cn>
To: shuah@...nel.org
Cc: abdulrasaqolawani@...il.com,
linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org,
liuye <liuye@...inos.cn>
Subject: [PATCH] selftests/acct/acct_syscall: Fix file descriptor leak
Exception branch returns without closing fp.
Signed-off-by: liuye <liuye@...inos.cn>
---
tools/testing/selftests/acct/acct_syscall.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/acct/acct_syscall.c b/tools/testing/selftests/acct/acct_syscall.c
index e44e8fe1f4a3..a8a4f8fc9ef9 100644
--- a/tools/testing/selftests/acct/acct_syscall.c
+++ b/tools/testing/selftests/acct/acct_syscall.c
@@ -54,6 +54,7 @@ int main(void)
if (child_pid < 0) {
ksft_test_result_error("Creating a child process to log failed\n");
acct(NULL);
+ fclose(fp);
return 1;
} else if (child_pid > 0) {
wait(NULL);
@@ -65,6 +66,7 @@ int main(void)
if (sz <= 0) {
ksft_test_result_fail("Terminated child process not logged\n");
ksft_exit_fail();
+ fclose(fp);
return 1;
}
@@ -73,6 +75,6 @@ int main(void)
ksft_exit_pass();
return 0;
}
-
+ fclose(fp);
return 1;
}
--
2.25.1
Powered by blists - more mailing lists