mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fixed an open function not judging the return value and closed the open function
@ 2023-12-04  8:05 liujing
  2023-12-04 19:37 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: liujing @ 2023-12-04  8:05 UTC (permalink / raw)
  To: shuah; +Cc: akpm, adobriyan, linux-kernel, linux-kselftest, liujing

Signed-off-by: liujing <liujing@cmss.chinamobile.com>
---
 tools/testing/selftests/proc/proc-pid-vm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/proc/proc-pid-vm.c b/tools/testing/selftests/proc/proc-pid-vm.c
index cacbd2a4aec9..5fc9b46f236f 100644
--- a/tools/testing/selftests/proc/proc-pid-vm.c
+++ b/tools/testing/selftests/proc/proc-pid-vm.c
@@ -205,7 +205,12 @@ static int make_exe(const uint8_t *payload, size_t len)
 	/* Avoid ETXTBSY on exec. */
 	snprintf(buf, sizeof(buf), "/proc/self/fd/%u", fd);
 	fd1 = open(buf, O_RDONLY|O_CLOEXEC);
+	if (fd == -1) {
+		exit(1);
+	}
+
 	close(fd);
+	close(fd1);
 
 	return fd1;
 }
-- 
2.18.2




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-04 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-04  8:05 [PATCH] Fixed an open function not judging the return value and closed the open function liujing
2023-12-04 19:37 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®