mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
Kernel: Ensure PhysicalRegion free page hint is within valid range
Fixes #3770
This commit is contained in:
parent
b98b83712f
commit
6fbced6f4f
1 changed files with 4 additions and 0 deletions
|
@ -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 {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue