[4/8] lazy-pages: handle_requests: fix return value propagation

Submitted by Mike Rapoport on April 16, 2018, 4:59 p.m.

Details

Message ID 1523897944-30193-5-git-send-email-rppt@linux.vnet.ibm.com
State Accepted
Series "lazy-pages: fixes"
Commit 9fe912f974cc1a273d1636c2414512a661d80aea
Headers show

Commit Message

Mike Rapoport April 16, 2018, 4:59 p.m.
When we return from epoll_run_rfds with positive return value it means that
event handling loop was interrupted because the event should be handled
outside of that loop. Is always the case with UFFD_EVENT_FORK.

It may happen that the event occurred after we've completed the memory
transfer and we are on the way to successful return from the
handle_requests() function, but instead of returning 0 we will return the
positive value we've got from epoll_run_rfds.

Explicitly assigning return value of complete_forks() fixes this issue.

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
---
 criu/uffd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/uffd.c b/criu/uffd.c
index 55de798..0343f93 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -1150,8 +1150,9 @@  static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds)
 		if (ret < 0)
 			goto out;
 		if (ret > 0) {
-			if (complete_forks(epollfd, &events, &nr_fds))
-				return -1;
+			ret = complete_forks(epollfd, &events, &nr_fds);
+			if (ret)
+				goto out;
 			if (!restore_finished)
 				continue;
 		}