mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +00:00
Kernel: Always observe the return value of Region::map and remap
We have seen cases where the map fails, but we return the region to the caller, causing them to page fault later on when they touch the region. The fix is to always observe the return code of map/remap.
This commit is contained in:
parent
0ae5de8c3c
commit
485f51690d
5 changed files with 28 additions and 12 deletions
|
@ -80,7 +80,10 @@ KResult AddressSpace::unmap_mmap_range(VirtualAddress addr, size_t size)
|
|||
|
||||
// And finally we map the new region(s) using our page directory (they were just allocated and don't have one).
|
||||
for (auto* new_region : new_regions) {
|
||||
new_region->map(page_directory());
|
||||
// TODO: Ideally we should do this in a way that can be rolled back on failure, as failing here
|
||||
// leaves the caller in an undefined state.
|
||||
if (!new_region->map(page_directory()))
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
PerformanceManager::add_unmap_perf_event(Process::current(), range_to_unmap);
|
||||
|
@ -130,7 +133,10 @@ KResult AddressSpace::unmap_mmap_range(VirtualAddress addr, size_t size)
|
|||
|
||||
// And finally map the new region(s) into our page directory.
|
||||
for (auto* new_region : new_regions) {
|
||||
new_region->map(page_directory());
|
||||
// TODO: Ideally we should do this in a way that can be rolled back on failure, as failing here
|
||||
// leaves the caller in an undefined state.
|
||||
if (!new_region->map(page_directory()))
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
PerformanceManager::add_unmap_perf_event(Process::current(), range_to_unmap);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue