diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-09-14 05:50:26 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-09-14 05:50:26 +0000 |
commit | c9f6fc3286d64db7694d320fecee7823f1570e69 (patch) | |
tree | 2ff13d61206888296d3ec14bc1ac21e814695d85 | |
parent | 92daddaad6afd2a83a144bb80eee8c78cbe8fed6 (diff) | |
parent | e045d9f873f2232e18b5a56db180af409b19b614 (diff) | |
download | gchips-android13-mainline-permission-release.tar.gz |
Snap for 9061588 from e045d9f873f2232e18b5a56db180af409b19b614 to mainline-permission-releaseaml_per_331913010aml_per_331812030aml_per_331710050aml_per_331611010aml_per_331512020aml_per_331411000aml_per_331313010aml_per_331115020android13-mainline-permission-release
Change-Id: Ie874c1768083221faa294fc4fdbf4f8c89699f9b
-rw-r--r-- | gralloc4/src/hidl_common/Allocator.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gralloc4/src/hidl_common/Allocator.cpp b/gralloc4/src/hidl_common/Allocator.cpp index 6ca758a..3b8e62a 100644 --- a/gralloc4/src/hidl_common/Allocator.cpp +++ b/gralloc4/src/hidl_common/Allocator.cpp @@ -77,7 +77,17 @@ void allocate(const buffer_descriptor_t &bufferDescriptor, uint32_t count, IAllo auto hnd = const_cast<private_handle_t *>(reinterpret_cast<const private_handle_t *>(tmpBuffer)); hnd->imapper_version = HIDL_MAPPER_VERSION_SCALED; + // 4k is rougly 7.9 MB with one byte per pixel. We are + // assuming that the reserved region might be needed for + // dynamic HDR and that represents the largest size. + uint64_t max_reserved_region_size = 8ull * 1024 * 1024; hnd->reserved_region_size = bufferDescriptor.reserved_size; + if (hnd->reserved_region_size > max_reserved_region_size) { + MALI_GRALLOC_LOGE("%s, Requested reserved region size (%" PRIu64 ") is larger than allowed (%" PRIu64 ")", + __func__, hnd->reserved_region_size, max_reserved_region_size); + error = Error::BAD_VALUE; + break; + } hnd->attr_size = mapper::common::shared_metadata_size() + hnd->reserved_region_size; if (hnd->get_usage() & GRALLOC_USAGE_ROIINFO) |