Kernel: Fix EINVAL when mmaping with address and no MAP_FIXED

The current behavior accidently trys to allocate 0 bytes when a non-null
address is provided and MAP_FIXED is specified. This is clearly a bug.
This commit is contained in:
Peter Elliott 2022-05-16 23:17:47 -06:00 committed by Andreas Kling
parent 0b9a9c7708
commit f6943c85b0

View file

@ -198,7 +198,7 @@ ErrorOr<FlatPtr> Process::sys$mmap(Userspace<Syscall::SC_mmap_params const*> use
Memory::VirtualRange requested_range { VirtualAddress { addr }, rounded_size };
if (addr && !(map_fixed || map_fixed_noreplace)) {
// If there's an address but MAP_FIXED wasn't specified, the address is just a hint.
requested_range = { {}, 0 };
requested_range = { {}, rounded_size };
}
if (map_anonymous) {