1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

Kernel: Handle OOM when adding memory regions to Spaces :^)

This commit is contained in:
Idan Horowitz 2021-07-15 01:18:00 +03:00 committed by Andreas Kling
parent e94dfb7355
commit be475cd6a8
3 changed files with 30 additions and 18 deletions

View file

@ -102,8 +102,13 @@ KResultOr<FlatPtr> Process::sys$fork(RegisterState& regs)
return ENOMEM;
}
auto& child_region = child->space().add_region(region_clone.release_nonnull());
child_region.map(child->space().page_directory(), ShouldFlushTLB::No);
auto* child_region = child->space().add_region(region_clone.release_nonnull());
if (!child_region) {
dbgln("fork: Cannot add region, insufficient memory");
// TODO: tear down new process?
return ENOMEM;
}
child_region->map(child->space().page_directory(), ShouldFlushTLB::No);
if (region == m_master_tls_region.unsafe_ptr())
child->m_master_tls_region = child_region;