mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
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.
This commit is contained in:
parent
cb71a73708
commit
75564b4a5f
40 changed files with 173 additions and 193 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue