diff options
author | Luke <luke.wilde@live.co.uk> | 2021-07-16 01:49:43 +0100 |
---|---|---|
committer | Gunnar Beutner <gunnar@beutner.name> | 2021-07-16 11:15:30 +0200 |
commit | 2df4d977e2060358a1b1261dc24804292bc39810 (patch) | |
tree | 3fa4799b15027a3ec2cb07b3c75d52c415eba7df /Kernel | |
parent | 41c0009f6d3db0f1a8baecbabc65c2464534dd31 (diff) | |
download | serenity-2df4d977e2060358a1b1261dc24804292bc39810.zip |
Kernel: Return ENOMEM on allocation failures in FramebufferDevice::mmap
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Graphics/FramebufferDevice.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Kernel/Graphics/FramebufferDevice.cpp b/Kernel/Graphics/FramebufferDevice.cpp index fad2e4e2c4..182e4ebc34 100644 --- a/Kernel/Graphics/FramebufferDevice.cpp +++ b/Kernel/Graphics/FramebufferDevice.cpp @@ -43,9 +43,20 @@ KResultOr<Region*> FramebufferDevice::mmap(Process& process, FileDescription&, c m_userspace_real_framebuffer_vmobject = vmobject; m_real_framebuffer_vmobject = AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, page_round_up(framebuffer_size_in_bytes())); + if (!m_real_framebuffer_vmobject) + return ENOMEM; + m_swapped_framebuffer_vmobject = AnonymousVMObject::try_create_with_size(page_round_up(framebuffer_size_in_bytes()), AllocationStrategy::AllocateNow); + if (!m_swapped_framebuffer_vmobject) + return ENOMEM; + m_real_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Region::Access::Read | Region::Access::Write); + if (!m_real_framebuffer_region) + return ENOMEM; + m_swapped_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Region::Access::Read | Region::Access::Write); + if (!m_swapped_framebuffer_region) + return ENOMEM; RefPtr<VMObject> chosen_vmobject; if (m_graphical_writes_enabled) { |