From 12cc41f671e775df9fae57f17ac73e7f39a64a01 Mon Sep 17 00:00:00 2001 From: Mike Rapoport Date: Mon, 16 Apr 2018 19:58:59 +0300 Subject: [PATCH] lazy-pages: merge_iov_lists: fix corner case of empty destination Signed-off-by: Mike Rapoport Signed-off-by: Andrei Vagin --- criu/uffd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/criu/uffd.c b/criu/uffd.c index 180ac4817..55de798ab 100644 --- a/criu/uffd.c +++ b/criu/uffd.c @@ -419,6 +419,14 @@ static void merge_iov_lists(struct list_head *src, struct list_head *dst) { struct lazy_iov *iov, *p, *n; + if (list_empty(src)) + return; + + if (list_empty(dst)) { + iov = list_first_entry(src, struct lazy_iov, l); + list_move(&iov->l, dst); + } + list_for_each_entry_safe(iov, n, src, l) { list_for_each_entry(p, dst, l) { if (iov->start < p->start) {