summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-01-14 19:01:51 +0200
committerIdan Horowitz <idan.horowitz@gmail.com>2022-01-14 19:42:11 +0200
commit1716105e738b91120905b53dddac389c39ce38dd (patch)
tree5848d9d46e5bbaff3be2be8f790b1a00d349b662
parent4ba9fa1a00131e994035063d2caa92202ca476ca (diff)
downloadserenity-1716105e738b91120905b53dddac389c39ce38dd.zip
Tests: Unmap memory ranges on /dev/mem after testing mmap(2)
-rw-r--r--Tests/Kernel/TestMemoryDeviceMmap.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/Tests/Kernel/TestMemoryDeviceMmap.cpp b/Tests/Kernel/TestMemoryDeviceMmap.cpp
index ef4a21ee80..40a983dce4 100644
--- a/Tests/Kernel/TestMemoryDeviceMmap.cpp
+++ b/Tests/Kernel/TestMemoryDeviceMmap.cpp
@@ -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 {