diff options
-rw-r--r-- | Kernel/VM/PhysicalRegion.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Kernel/VM/PhysicalRegion.cpp b/Kernel/VM/PhysicalRegion.cpp index 1c61350874..8cac4d77e4 100644 --- a/Kernel/VM/PhysicalRegion.cpp +++ b/Kernel/VM/PhysicalRegion.cpp @@ -156,11 +156,12 @@ void PhysicalRegion::free_page_at(PhysicalAddress addr) ASSERT_NOT_REACHED(); } - ptrdiff_t local_offset = addr.get() - m_lower.get(); - ASSERT(local_offset >= 0); - ASSERT((FlatPtr)local_offset < (FlatPtr)(m_pages * PAGE_SIZE)); + Checked<FlatPtr> local_offset = addr.get(); + local_offset -= m_lower.get(); + ASSERT(!local_offset.has_overflow()); + ASSERT(local_offset.value() < (FlatPtr)(m_pages * PAGE_SIZE)); - auto page = (FlatPtr)local_offset / PAGE_SIZE; + auto page = local_offset.value() / PAGE_SIZE; m_bitmap.set(page, false); m_free_hint = page; // We know we can find one here for sure m_used--; |