1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 09:57:35 +00:00

Kernel: Assert if rounding-up-to-page-size would wrap around to 0

If we try to align a number above 0xfffff000 to the next multiple of
the page size (4 KiB), it would wrap around to 0. This is most likely
never what we want, so let's assert if that happens.
This commit is contained in:
Andreas Kling 2021-02-14 09:57:19 +01:00
parent 198d641808
commit 09b1b09c19
19 changed files with 67 additions and 40 deletions

View file

@ -108,7 +108,7 @@ struct KmallocGlobalHeap {
// was big enough to likely satisfy the request
if (subheap.free_bytes() < allocation_request) {
// Looks like we probably need more
size_t memory_size = PAGE_ROUND_UP(decltype(m_global_heap.m_heap)::calculate_memory_for_bytes(allocation_request));
size_t memory_size = page_round_up(decltype(m_global_heap.m_heap)::calculate_memory_for_bytes(allocation_request));
// Add some more to the new heap. We're already using it for other
// allocations not including the original allocation_request
// that triggered heap expansion. If we don't allocate