* [PATCH] tools: selftests: Add missing munmap() in check_error_paths()
@ 2020-11-27 5:49 Youling Tang
0 siblings, 0 replies; only message in thread
From: Youling Tang @ 2020-11-27 5:49 UTC (permalink / raw)
To: Shuah Khan; +Cc: linux-kselftest, linux-kernel
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-27 5:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27 5:49 [PATCH] tools: selftests: Add missing munmap() in check_error_paths() Youling Tang
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.