[05/12] lib/infect: Check if compel succeed in executing munmap

Submitted by Dmitry Safonov on Nov. 9, 2019, 10:20 p.m.

Details

Message ID 20191109222045.89507-6-dima@arista.com
State Accepted
Series "compel: Add __must_check"
Commit 3325ae2ba62e9a2514e5f431fd29245441d15efb
Headers show

Commit Message

Dmitry Safonov Nov. 9, 2019, 10:20 p.m.
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 compel/arch/s390/src/lib/infect.c |  4 +++-
 compel/src/lib/infect.c           | 10 +++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/compel/arch/s390/src/lib/infect.c b/compel/arch/s390/src/lib/infect.c
index 00e9c36d21a1..7e7d24ce215f 100644
--- a/compel/arch/s390/src/lib/infect.c
+++ b/compel/arch/s390/src/lib/infect.c
@@ -453,8 +453,10 @@  void *remote_mmap(struct parasite_ctl *ctl,
 	if (ptrace_poke_area(pid, &arg_struct, where, sizeof(arg_struct))) {
 		pr_err("Can't restore mmap args (pid: %d)\n", pid);
 		if (map != 0) {
-			compel_syscall(ctl, __NR_munmap, NULL, map,
+			err = compel_syscall(ctl, __NR_munmap, NULL, map,
 					     length, 0, 0, 0, 0);
+			if (err)
+				pr_err("Can't munmap %d\n", err);
 			map = 0;
 		}
 	}
diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index 656cc030d402..8b377e7d22d8 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -1303,6 +1303,7 @@  int compel_stop_daemon(struct parasite_ctl *ctl)
 int compel_cure_remote(struct parasite_ctl *ctl)
 {
 	long ret;
+	int err;
 
 	if (compel_stop_daemon(ctl))
 		return -1;
@@ -1310,9 +1311,12 @@  int compel_cure_remote(struct parasite_ctl *ctl)
 	if (!ctl->remote_map)
 		return 0;
 
-	compel_syscall(ctl, __NR(munmap, !compel_mode_native(ctl)), &ret,
-			(unsigned long)ctl->remote_map, ctl->map_length,
-			0, 0, 0, 0);
+	err = compel_syscall(ctl, __NR(munmap, !compel_mode_native(ctl)), &ret,
+			     (unsigned long)ctl->remote_map, ctl->map_length,
+			     0, 0, 0, 0);
+	if (err)
+		return err;
+
 	if (ret) {
 		pr_err("munmap for remote map %p, %lu returned %lu\n",
 				ctl->remote_map, ctl->map_length, ret);