Skip to content

Commit a6cf527

Browse files
committed
preload: don't try to free a zero-size region
in kmem_bootstrap_free() we round the start and end of the range to free to avoid freeing unrelated records might share the first or last pages of the range we are freeing. this rounding can result in a range that is zero or negative size (though negative becomes large positive because the types are unsigned). in this case there is nothing that can actually be freed, so just return early.
1 parent 7216b1e commit a6cf527

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sys/vm/vm_kern.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,14 @@ kmem_bootstrap_free(vm_offset_t start, vm_size_t size)
948948
end = trunc_page(start + size);
949949
start = round_page(start);
950950

951+
/*
952+
* If rounding to page boundaries leaves us with nothing to free,
953+
* just return now. vmem_add() will fail an assertion if we call it
954+
* with a zero size.
955+
*/
956+
if (end <= start)
957+
return;
958+
951959
#ifdef __amd64__
952960
/*
953961
* Preloaded files do not have execute permissions by default on amd64.

0 commit comments

Comments
 (0)