[PATCH] selftests/acct/acct_syscall: Fix file descriptor leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



    Exception branch returns without closing fp.
Signed-off-by: liuye <liuye@xxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux