vhost_user: 'nregions' saves the actual number of mapped guest physical address area
This patch fixed the VMA leak that if mapping one of guest physical address area get failed.
Change-Id: I07b0b9a932209561d6ff2b2dd08a111ea5db2209
Signed-off-by: Haiyang Tan <haiyang.tan.dev@gmail.com>
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c
index 7470f15..c782040 100644
--- a/src/vnet/devices/virtio/vhost-user.c
+++ b/src/vnet/devices/virtio/vhost-user.c
@@ -852,8 +852,9 @@
}
vui->region_mmap_addr[i] += vui->regions[i].mmap_offset;
vui->region_mmap_fd[i] = fds[i];
+
+ vui->nregions++;
}
- vui->nregions = msg.memory.nregions;
break;
case VHOST_USER_SET_VRING_NUM: