diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-05-14 05:06:29 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-15 09:01:32 +0200 |
commit | a324d4d6a342ad6847697c32f127c31ea76f6e61 (patch) | |
tree | 8e5b1cbeeedf8b9b66e35f35cd248e61cbd9e5d3 /Kernel/Devices | |
parent | d45db06826461886b69a832ae34f933d3b613fc7 (diff) | |
download | serenity-a324d4d6a342ad6847697c32f127c31ea76f6e61.zip |
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.
Diffstat (limited to 'Kernel/Devices')
-rw-r--r-- | Kernel/Devices/SB16.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp index fa48d20db8..2ae61c8ad2 100644 --- a/Kernel/Devices/SB16.cpp +++ b/Kernel/Devices/SB16.cpp @@ -230,6 +230,8 @@ KResultOr<size_t> SB16::write(FileDescription&, u64, const UserOrKernelBuffer& d if (!page) return ENOMEM; auto vmobject = AnonymousVMObject::create_with_physical_page(*page); + if (!vmobject) + return ENOMEM; m_dma_region = MM.allocate_kernel_region_with_vmobject(*vmobject, PAGE_SIZE, "SB16 DMA buffer", Region::Access::Write); if (!m_dma_region) return ENOMEM; |