summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2020-10-16 09:35:23 -0600
committerAndreas Kling <kling@serenityos.org>2020-10-16 17:39:42 +0200
commit6fbced6f4f690f60385edb2bd28e62fc08019606 (patch)
treed85a01ffb7d545c1c1b70695b80d4007d116c7db /Kernel
parentb98b83712f2d6a5756ad9464f6ff81d9489789cb (diff)
downloadserenity-6fbced6f4f690f60385edb2bd28e62fc08019606.zip
Kernel: Ensure PhysicalRegion free page hint is within valid range
Fixes #3770
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/VM/PhysicalRegion.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/VM/PhysicalRegion.cpp b/Kernel/VM/PhysicalRegion.cpp
index df28105d65..1c61350874 100644
--- a/Kernel/VM/PhysicalRegion.cpp
+++ b/Kernel/VM/PhysicalRegion.cpp
@@ -112,6 +112,8 @@ Optional<unsigned> PhysicalRegion::find_one_free_page()
m_bitmap.set(page_index, true);
m_used++;
m_free_hint = free_index.value() + 1; // Just a guess
+ if (m_free_hint >= m_bitmap.size())
+ m_free_hint = 0;
return page_index;
}
@@ -128,6 +130,8 @@ Optional<unsigned> PhysicalRegion::find_and_allocate_contiguous_range(size_t cou
m_bitmap.set_range<true>(page, count);
m_used += count;
m_free_hint = first_index.value() + count + 1; // Just a guess
+ if (m_free_hint >= m_bitmap.size())
+ m_free_hint = 0;
return page;
}
return {};