Skip to content

Commit bccdc08

Browse files
committed
Kernel: Unmapping a non-mapped region with munmap() should be a no-op
Not a regression per se from 0fcb9ef since we were crashing before that which is obviously worse.
1 parent c9395d7 commit bccdc08

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Kernel/VM/Space.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ KResult Space::unmap_mmap_range(VirtualAddress addr, size_t size)
9292
// Try again while checking multiple regions at a time.
9393
auto const& regions = find_regions_intersecting(range_to_unmap);
9494
if (regions.is_empty())
95-
return EINVAL;
95+
return KSuccess;
9696

9797
// Check if any of the regions is not mmap'ed, to not accidentally
9898
// error out with just half a region map left.

Tests/Kernel/TestMunMap.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
TEST_CASE(munmap_zero_page)
1212
{
13-
// munmap of the unmapped zero page should always fail.
13+
// munmap of the unmapped zero page should always "succeed".
1414
auto res = munmap(0x0, 0xF);
15-
EXPECT_EQ(res, -1);
16-
EXPECT_EQ(errno, EINVAL);
15+
EXPECT_EQ(res, 0);
1716
}

0 commit comments

Comments
 (0)