diff mbox series

tools: selftests: Add missing munmap() in check_error_paths()

Message ID 1606456195-23965-1-git-send-email-tangyouling@loongson.cn
State New
Headers show
Series tools: selftests: Add missing munmap() in check_error_paths() | expand

Commit Message

Youling Tang Nov. 27, 2020, 5:49 a.m. UTC
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 mbox series

Patch

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