Check the mprotect() result when initializing the JIT code cache.
Bug: 2690371
Change-Id: I48cb6498d1cdddcbf8386649d02467db5a1306e8
diff --git a/vm/compiler/Compiler.c b/vm/compiler/Compiler.c
index 9b32703..2368dae 100644
--- a/vm/compiler/Compiler.c
+++ b/vm/compiler/Compiler.c
@@ -180,8 +180,13 @@
cacheflush((intptr_t) gDvmJit.codeCache,
(intptr_t) gDvmJit.codeCache + templateSize, 0);
- mprotect(gDvmJit.codeCache, gDvmJit.codeCacheSize,
- PROTECT_CODE_CACHE_ATTRS);
+ int result = mprotect(gDvmJit.codeCache, gDvmJit.codeCacheSize,
+ PROTECT_CODE_CACHE_ATTRS);
+
+ if (result == -1) {
+ LOGE("Failed to remove the write permission for the code cache");
+ dvmAbort();
+ }
return true;
}