diff --git a/cr-restore.c b/cr-restore.c index 4df9e6f8a..ab71e2fe8 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -194,12 +194,13 @@ static int read_vmas(int pid, struct list_head *vmas, int *nr_vmas) if (!vma) break; - (*nr_vmas)++; - list_add_tail(&vma->list, vmas); ret = pb_read_one_eof(fd, &e, PB_VMAS); if (ret <= 0) break; + (*nr_vmas)++; + list_add_tail(&vma->list, vmas); + if (e->fd != -1) { ret = -1; pr_err("Error in vma->fd setting (%Ld)\n",