All of lore.kernel.org
 help / color / mirror / Atom feed
From: liujing <liujing@cmss.chinamobile.com>
To: shuah@kernel.org
Cc: akpm@linux-foundation.org, adobriyan@gmail.com,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	liujing <liujing@cmss.chinamobile.com>
Subject: [PATCH] Fixed an open function not judging the return value and closed the open function
Date: Mon,  4 Dec 2023 03:05:54 -0500	[thread overview]
Message-ID: <20231204080554.2424-1-liujing@cmss.chinamobile.com> (raw)

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




             reply	other threads:[~2023-12-04  8:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04  8:05 liujing [this message]
2023-12-04 19:37 ` [PATCH] Fixed an open function not judging the return value and closed the open function Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231204080554.2424-1-liujing@cmss.chinamobile.com \
    --to=liujing@cmss.chinamobile.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.