mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
Kernel: Ensure PhysicalRegion free page hint is within valid range
Fixes #3770
This commit is contained in:
parent
b98b83712f
commit
6fbced6f4f
Notes:
sideshowbarker
2024-07-19 01:53:03 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/6fbced6f4f6 Pull-request: https://github.com/SerenityOS/serenity/pull/3782 Issue: https://github.com/SerenityOS/serenity/issues/3770
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
Reference in a new issue