metrics-ipmi-blobs: Fix memory leak with readMem
Add `munmap` after `mmap` succeeded.
Otherwise it might cause memory after 65500+ times.
Tested:
(Provided by @suichen)
```
Without munmap:
/tmp# ./mmap_test
...
65100 mmaps
65200 mmaps
65300 mmaps
65400 mmaps
65500 mmaps
ERR: 12
ERROR with 65503 mmaps
ERR: 12
-----------------------------------------------------------------
With unmap:
/tmp# WITH_UNMAP=1 ./mmap_test
...
161700 mmaps
161800 mmaps
161900 mmaps
162000 mmaps
162100 mmaps
162200 mmaps
...
```
Signed-off-by: Michael Shen <gpgpgp@google.com>
Change-Id: Ie68d4f42337ca3459ae60dc1f649ed1b25631b17
diff --git a/subprojects/metrics-ipmi-blobs/util.cpp b/subprojects/metrics-ipmi-blobs/util.cpp
index 92cb80c..3057cfb 100644
--- a/subprojects/metrics-ipmi-blobs/util.cpp
+++ b/subprojects/metrics-ipmi-blobs/util.cpp
@@ -256,6 +256,7 @@
char* virtAddr = reinterpret_cast<char*>(mapBase) + offsetInPage;
memResult = *(reinterpret_cast<uint32_t*>(virtAddr));
close(fd);
+ munmap(mapBase, pageSize * 2);
return true;
}