It is okay to free up to the very last page of virtual address space, in which case mem+size is zero. Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> --- lib/alloc_page.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/alloc_page.c b/lib/alloc_page.c index b02dfce..de6fd6f 100644 --- a/lib/alloc_page.c +++ b/lib/alloc_page.c @@ -19,7 +19,8 @@ void free_pages(void *mem, unsigned long size) assert_msg(size % PAGE_SIZE == 0, "size not page aligned: %#lx", size); - assert_msg(size == 0 || mem + size > mem, + assert_msg(size == 0 || (uintptr_t)mem == -size || + (uintptr_t)mem + size > (uintptr_t)mem, "mem + size overflow: %p + %#lx", mem, size); if (size == 0) { -- 2.14.2