From 9f0dce3ec6f5e47931900dd0d6abe42078a9c1e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EA=B9=80=EC=88=98=EC=A7=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Wed, 25 Apr 2018 14:57:27 +0900 Subject: [PATCH] Check if ashmem region is created. (#878) This commit checks if ashmem region is created. Signed-off-by: sjsujinkim --- src/runtime/ref/nn/runtime/Memory.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/ref/nn/runtime/Memory.cpp b/src/runtime/ref/nn/runtime/Memory.cpp index 61d8e12..f2ab196 100644 --- a/src/runtime/ref/nn/runtime/Memory.cpp +++ b/src/runtime/ref/nn/runtime/Memory.cpp @@ -31,6 +31,10 @@ namespace nn { int Memory::create(uint32_t size) { int fd = ashmem_create_region("__unused_name", size); + if (fd == -1) { + LOG(ERROR) << "Failed to create ashmem region."; + return ANEURALNETWORKS_UNEXPECTED_NULL; + } int prot = PROT_WRITE | PROT_READ; size_t offset = 0; void* data = mmap(0, size, prot, MAP_SHARED, fd, offset); -- 2.7.4