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; }