[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250114080410.108067-1-liuye@kylinos.cn>
Date: Tue, 14 Jan 2025 16:04:10 +0800
From: liuye <liuye@...inos.cn>
To: shuah@...nel.org
Cc: linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org,
liuye <liuye@...inos.cn>
Subject: [PATCH] selftests/prctl/set-process-name: Fix Resource leak fptr in check_name
Exception branch returns without closing fptr.
Signed-off-by: liuye <liuye@...inos.cn>
---
tools/testing/selftests/prctl/set-process-name.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/prctl/set-process-name.c b/tools/testing/selftests/prctl/set-process-name.c
index 562f707ba771..625218fa0379 100644
--- a/tools/testing/selftests/prctl/set-process-name.c
+++ b/tools/testing/selftests/prctl/set-process-name.c
@@ -66,14 +66,18 @@ int check_name(void)
return -EIO;
fscanf(fptr, "%s", output);
- if (ferror(fptr))
+ if (ferror(fptr)) {
+ fclose(fptr);
return -EIO;
+ }
int res = prctl(PR_GET_NAME, name, NULL, NULL, NULL);
- if (res < 0)
+ if (res < 0) {
+ fclose(fptr);
return -errno;
-
+ }
+ fclose(fptr);
return !strcmp(output, name);
}
--
2.25.1
Powered by blists - more mailing lists