lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20241128061827.4165-1-liujing@cmss.chinamobile.com>
Date: Thu, 28 Nov 2024 14:18:27 +0800
From: liujing <liujing@...s.chinamobile.com>
To: shuah@...nel.org,
	osmtendev@...il.com
Cc: linux-kselftest@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	liujing <liujing@...s.chinamobile.com>
Subject: [PATCH] selftests: prctl: Fix resource leaks

After using the fopen function successfully, you need to call
fclose to close the file before finally returning.

Signed-off-by: liujing <liujing@...s.chinamobile.com>

diff --git a/tools/testing/selftests/prctl/set-process-name.c b/tools/testing/selftests/prctl/set-process-name.c
index 562f707ba771..7be7afff0cd2 100644
--- a/tools/testing/selftests/prctl/set-process-name.c
+++ b/tools/testing/selftests/prctl/set-process-name.c
@@ -66,9 +66,12 @@ int check_name(void)
 		return -EIO;
 
 	fscanf(fptr, "%s", output);
-	if (ferror(fptr))
+	if (ferror(fptr)) {
+		fclose(fptr);
 		return -EIO;
+	}
 
+	fclose(fptr);
 	int res = prctl(PR_GET_NAME, name, NULL, NULL, NULL);
 
 	if (res < 0)
-- 
2.27.0




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ