Browse Source

Kernel: Hoist VERIFY from a loop in RangeAllocator::allocate_specific()

Andreas Kling 4 years ago
parent
commit
b0d9b88c49
1 changed files with 3 additions and 2 deletions
  1. 3 2
      Kernel/VM/RangeAllocator.cpp

+ 3 - 2
Kernel/VM/RangeAllocator.cpp

@@ -136,11 +136,12 @@ Optional<Range> RangeAllocator::allocate_specific(VirtualAddress base, size_t si
     VERIFY(base.is_page_aligned());
     VERIFY((size % PAGE_SIZE) == 0);
 
-    Range allocated_range(base, size);
+    Range const allocated_range(base, size);
+    VERIFY(m_total_range.contains(allocated_range));
+
     ScopedSpinLock lock(m_lock);
     for (size_t i = 0; i < m_available_ranges.size(); ++i) {
         auto& available_range = m_available_ranges[i];
-        VERIFY(m_total_range.contains(allocated_range));
         if (!available_range.contains(base, size))
             continue;
         if (available_range == allocated_range) {