Message ID | 20250114033456.62179-1-liuye@kylinos.cn (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | selftests/acct/acct_syscall: Fix file descriptor leak | expand |
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; }
Exception branch returns without closing fp. Signed-off-by: liuye <liuye@kylinos.cn> --- tools/testing/selftests/acct/acct_syscall.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)