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

Kernel: Make ContiguousVMObject factory API OOM safe

This commit is contained in:
Brian Gianforcaro 2021-05-28 03:56:42 -07:00 committed by Andreas Kling
parent cb45b2c001
commit 864b1a65e3
3 changed files with 17 additions and 11 deletions

View file

@ -464,7 +464,11 @@ OwnPtr<Region> MemoryManager::allocate_contiguous_kernel_region(size_t size, Str
if (!range.has_value())
return {};
auto vmobject = ContiguousVMObject::create_with_size(size, physical_alignment);
return allocate_kernel_region_with_vmobject(range.value(), vmobject, name, access, cacheable);
if (!vmobject) {
kernel_page_directory().range_allocator().deallocate(range.value());
return {};
}
return allocate_kernel_region_with_vmobject(range.value(), *vmobject, name, access, cacheable);
}
OwnPtr<Region> MemoryManager::allocate_kernel_region(size_t size, StringView name, Region::Access access, AllocationStrategy strategy, Region::Cacheable cacheable)