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

Kernel: Make AnonymousVMObject physical page APIs OOM safe

AnonymousVMObject::create_with_physical_page(s) can't be NonnullRefPtr
as it allocates internally. Fixing the API then surfaced an issue in
ScatterGatherList, where the code was attempting to create an
AnonymousVMObject in the constructor which will not be observable
during OOM.

Fix all of these issues and start propagating errors at the callers
of the AnonymousVMObject and ScatterGatherList APis.
This commit is contained in:
Brian Gianforcaro 2021-05-14 05:06:29 -07:00 committed by Andreas Kling
parent d45db06826
commit a324d4d6a3
6 changed files with 20 additions and 13 deletions

View file

@ -60,14 +60,14 @@ RefPtr<AnonymousVMObject> AnonymousVMObject::create_with_size(size_t size, Alloc
return adopt_ref_if_nonnull(new AnonymousVMObject(size, commit));
}
NonnullRefPtr<AnonymousVMObject> AnonymousVMObject::create_with_physical_pages(NonnullRefPtrVector<PhysicalPage> physical_pages)
RefPtr<AnonymousVMObject> AnonymousVMObject::create_with_physical_pages(NonnullRefPtrVector<PhysicalPage> physical_pages)
{
return adopt_ref(*new AnonymousVMObject(physical_pages));
return adopt_ref_if_nonnull(new AnonymousVMObject(physical_pages));
}
NonnullRefPtr<AnonymousVMObject> AnonymousVMObject::create_with_physical_page(PhysicalPage& page)
RefPtr<AnonymousVMObject> AnonymousVMObject::create_with_physical_page(PhysicalPage& page)
{
return adopt_ref(*new AnonymousVMObject(page));
return adopt_ref_if_nonnull(new AnonymousVMObject(page));
}
RefPtr<AnonymousVMObject> AnonymousVMObject::create_for_physical_range(PhysicalAddress paddr, size_t size)