diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-06 01:36:14 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-06 01:55:27 +0200 |
commit | 75564b4a5f2b5452163571116ee9efaf5c3c65af (patch) | |
tree | ec672e92fcf3e7dca6ed51bce1c287319a9fc77d /Kernel/Devices | |
parent | cb71a7370836c3b70038e2f718ee87f6fc286229 (diff) | |
download | serenity-75564b4a5f2b5452163571116ee9efaf5c3c65af.zip |
Kernel: Make kernel region allocators return KResultOr<NOP<Region>>
This expands the reach of error propagation greatly throughout the
kernel. Sadly, it also exposes the fact that we're allocating (and
doing other fallible things) in constructors all over the place.
This patch doesn't attempt to address that of course. That's work for
our future selves.
Diffstat (limited to 'Kernel/Devices')
-rw-r--r-- | Kernel/Devices/KCOVInstance.cpp | 6 | ||||
-rw-r--r-- | Kernel/Devices/SB16.cpp | 4 |
2 files changed, 3 insertions, 7 deletions
diff --git a/Kernel/Devices/KCOVInstance.cpp b/Kernel/Devices/KCOVInstance.cpp index a602dacc18..000bbb10cb 100644 --- a/Kernel/Devices/KCOVInstance.cpp +++ b/Kernel/Devices/KCOVInstance.cpp @@ -33,11 +33,9 @@ KResult KCOVInstance::buffer_allocate(size_t buffer_size_in_entries) return maybe_vmobject.error(); m_vmobject = maybe_vmobject.release_value(); - m_kernel_region = MM.allocate_kernel_region_with_vmobject( + m_kernel_region = TRY(MM.allocate_kernel_region_with_vmobject( *m_vmobject, m_buffer_size_in_bytes, String::formatted("kcov_{}", m_pid), - Memory::Region::Access::ReadWrite); - if (!m_kernel_region) - return ENOMEM; + Memory::Region::Access::ReadWrite)); m_buffer = (u64*)m_kernel_region->vaddr().as_ptr(); if (!has_buffer()) diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp index 473b04e750..ebeb6cfc2d 100644 --- a/Kernel/Devices/SB16.cpp +++ b/Kernel/Devices/SB16.cpp @@ -263,9 +263,7 @@ KResultOr<size_t> SB16::write(FileDescription&, u64, UserOrKernelBuffer const& d return ENOMEM; auto nonnull_page = page.release_nonnull(); auto vmobject = TRY(Memory::AnonymousVMObject::try_create_with_physical_pages({ &nonnull_page, 1 })); - m_dma_region = MM.allocate_kernel_region_with_vmobject(move(vmobject), PAGE_SIZE, "SB16 DMA buffer", Memory::Region::Access::Write); - if (!m_dma_region) - return ENOMEM; + m_dma_region = TRY(MM.allocate_kernel_region_with_vmobject(move(vmobject), PAGE_SIZE, "SB16 DMA buffer", Memory::Region::Access::Write)); } dbgln_if(SB16_DEBUG, "SB16: Writing buffer of {} bytes", length); |