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/Syscalls/execve.cpp | |
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/Syscalls/execve.cpp')
-rw-r--r-- | Kernel/Syscalls/execve.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 498580dff8..716a77a5e6 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -173,12 +173,7 @@ static KResultOr<RequiredLoadRange> get_required_load_range(FileDescription& pro size_t executable_size = inode.size(); - auto region = MM.allocate_kernel_region_with_vmobject(*vmobject, Memory::page_round_up(executable_size), "ELF memory range calculation", Memory::Region::Access::Read); - if (!region) { - dbgln("Could not allocate memory for ELF"); - return ENOMEM; - } - + auto region = TRY(MM.allocate_kernel_region_with_vmobject(*vmobject, Memory::page_round_up(executable_size), "ELF memory range calculation", Memory::Region::Access::Read)); auto elf_image = ELF::Image(region->vaddr().as_ptr(), executable_size); if (!elf_image.is_valid()) { return EINVAL; @@ -283,12 +278,7 @@ static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Memory::AddressSpace> size_t executable_size = inode.size(); - auto executable_region = MM.allocate_kernel_region_with_vmobject(*vmobject, Memory::page_round_up(executable_size), "ELF loading", Memory::Region::Access::Read); - if (!executable_region) { - dbgln("Could not allocate memory for ELF loading"); - return ENOMEM; - } - + auto executable_region = TRY(MM.allocate_kernel_region_with_vmobject(*vmobject, Memory::page_round_up(executable_size), "ELF loading", Memory::Region::Access::Read)); auto elf_image = ELF::Image(executable_region->vaddr().as_ptr(), executable_size); if (!elf_image.is_valid()) |