Kernel: Make AddressSpace::add_region() return KResultOr<Region*>

This allows us to use TRY() in a few places.
This commit is contained in:
Andreas Kling 2021-09-06 02:02:06 +02:00
parent 062cc804e7
commit a994f11f10
Notes: sideshowbarker 2024-07-18 04:38:46 +09:00
3 changed files with 9 additions and 20 deletions

View file

@ -94,12 +94,7 @@ KResultOr<FlatPtr> Process::sys$fork(RegisterState& regs)
for (auto& region : address_space().regions()) {
dbgln_if(FORK_DEBUG, "fork: cloning Region({}) '{}' @ {}", region, region->name(), region->vaddr());
auto region_clone = TRY(region->try_clone());
auto* child_region = child->address_space().add_region(move(region_clone));
if (!child_region) {
dbgln("fork: Cannot add region, insufficient memory");
// TODO: tear down new process?
return ENOMEM;
}
auto* child_region = TRY(child->address_space().add_region(move(region_clone)));
if (!child_region->map(child->address_space().page_directory(), Memory::ShouldFlushTLB::No))
return ENOMEM;