Tests: Unmap memory ranges on /dev/mem after testing mmap(2)

This commit is contained in:
Liav A 2022-01-14 19:01:51 +02:00 committed by Idan Horowitz
parent 4ba9fa1a00
commit 1716105e73
Notes: sideshowbarker 2024-07-17 20:54:49 +09:00

View File

@ -23,7 +23,11 @@ static ALWAYS_INLINE bool mem_chunk(int fd, u64 base, u64 length)
{
u64 mmoffset = base % sysconf(_SC_PAGESIZE);
void* mmp = mmap(NULL, mmoffset + length, PROT_READ, MAP_SHARED, fd, base - mmoffset);
return mmp != MAP_FAILED;
if (mmp == MAP_FAILED)
return false;
if (munmap(mmp, mmoffset + length) < 0)
perror("munmap");
return true;
}
enum class ReadResult {