1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

Kernel: Convert MemoryManager::allocate_user_physical_page to ErrorOr

This allows is to use the TRY macro at the call sites, instead of using
clunky null checks.
This commit is contained in:
Idan Horowitz 2022-01-28 16:36:53 +02:00
parent bd5b56cab0
commit 5146315a15
6 changed files with 20 additions and 23 deletions

View file

@ -322,11 +322,12 @@ PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, Virtual
page = m_shared_committed_cow_pages->take_one();
} else {
dbgln_if(PAGE_FAULT_DEBUG, " >> It's a COW page and it's time to COW!");
page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::No);
if (page.is_null()) {
auto page_or_error = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::No);
if (page_or_error.is_error()) {
dmesgln("MM: handle_cow_fault was unable to allocate a physical page");
return PageFaultResponse::OutOfMemory;
}
page = page_or_error.release_value();
}
dbgln_if(PAGE_FAULT_DEBUG, " >> COW {} <- {}", page->paddr(), page_slot->paddr());