summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-07 00:17:25 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-07 00:17:25 +0000
commited3cfaa6b0d353bc330fb816d01fcfd436d6ceb0 (patch)
tree4d5361267488f8a1fd1d837a608e87899b5878db
parent2cfcdca8cc047b21e1361a4dd93f1d4e3d5dfeaa (diff)
parent299507996fa4f1a8c9dfa1eaee8b0c23d2802eed (diff)
downloadgchips-ed3cfaa6b0d353bc330fb816d01fcfd436d6ceb0.tar.gz
Snap for 11186783 from 299507996fa4f1a8c9dfa1eaee8b0c23d2802eed to 24Q1-release
Change-Id: Ia8c77a10c8363d0680dfadc07926a1e36baf9c75
-rw-r--r--gralloc4/src/allocator/mali_gralloc_ion.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/gralloc4/src/allocator/mali_gralloc_ion.cpp b/gralloc4/src/allocator/mali_gralloc_ion.cpp
index 3a955d9..c66c54a 100644
--- a/gralloc4/src/allocator/mali_gralloc_ion.cpp
+++ b/gralloc4/src/allocator/mali_gralloc_ion.cpp
@@ -30,6 +30,7 @@
#include <utils/Trace.h>
#include <linux/dma-buf.h>
+#include <linux/memfd.h>
#include <vector>
#include <sys/ioctl.h>
@@ -222,7 +223,12 @@ int alloc_from_dmabuf_heap(uint64_t usage, size_t size, const std::string& buffe
std::stringstream tag;
tag << "heap: " << heap_name << ", bytes: " << size;
ATRACE_NAME(tag.str().c_str());
- int shared_fd = get_allocator().Alloc(heap_name, size, 0);
+ int shared_fd = -1;
+
+ // memfd requires matching sepolicy allowing r/w access to tmpfs.
+ if (use_placeholder) shared_fd = memfd_create(heap_name.c_str(), 0);
+ else shared_fd = get_allocator().Alloc(heap_name, size, 0);
+
if (shared_fd < 0)
{
ALOGE("Allocation failed for heap %s error: %d\n", heap_name.c_str(), shared_fd);