All of lore.kernel.org
 help / color / mirror / Atom feed
From: Youling Tang <tangyouling@loongson.cn>
To: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] tools: selftests: Add missing munmap() in check_error_paths()
Date: Fri, 27 Nov 2020 13:49:55 +0800	[thread overview]
Message-ID: <1606456195-23965-1-git-send-email-tangyouling@loongson.cn> (raw)

Add the missing munmap(addr_ro, PAGE_SIZE) before return.

Signed-off-by: Youling Tang <tangyouling@loongson.cn>
---
 tools/testing/selftests/ptrace/peeksiginfo.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/ptrace/peeksiginfo.c b/tools/testing/selftests/ptrace/peeksiginfo.c
index 5490065..3d64be4 100644
--- a/tools/testing/selftests/ptrace/peeksiginfo.c
+++ b/tools/testing/selftests/ptrace/peeksiginfo.c
@@ -62,7 +62,7 @@ static int check_error_paths(pid_t child)
 			MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
 	if (addr_ro == MAP_FAILED) {
 		err("mmap() failed: %m\n");
-		goto out;
+		goto out_rw;
 	}
 
 	arg.nr = SIGNR;
@@ -75,7 +75,7 @@ static int check_error_paths(pid_t child)
 		err("sys_ptrace() returns %d (expected -1),"
 				" errno %d (expected %d): %m\n",
 				ret, errno, EINVAL);
-		goto out;
+		goto out_ro;
 	}
 	arg.flags = 0;
 
@@ -84,7 +84,7 @@ static int check_error_paths(pid_t child)
 					addr_ro - sizeof(siginfo_t) * 2);
 	if (ret != 2) {
 		err("sys_ptrace() returns %d (expected 2): %m\n", ret);
-		goto out;
+		goto out_ro;
 	}
 
 	/* Read-only buffer */
@@ -93,11 +93,13 @@ static int check_error_paths(pid_t child)
 		err("sys_ptrace() returns %d (expected -1),"
 				" errno %d (expected %d): %m\n",
 				ret, errno, EFAULT);
-		goto out;
+		goto out_ro;
 	}
 
 	exit_code = 0;
-out:
+out_ro:
+	munmap(addr_ro, PAGE_SIZE);
+out_rw:
 	munmap(addr_rw, 2 * PAGE_SIZE);
 	return exit_code;
 }
-- 
2.1.0


                 reply	other threads:[~2020-11-27  5:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1606456195-23965-1-git-send-email-tangyouling@loongson.cn \
    --to=tangyouling@loongson.cn \
    --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.