summaryrefslogtreecommitdiff
path: root/sdm/libs/hwc2/hwc_buffer_allocator.cpp
diff options
context:
space:
mode:
authorRamakant Singh <ramakant@codeaurora.org>2019-10-04 20:02:45 +0530
committerRamakant Singh <ramakant@codeaurora.org>2019-10-14 10:30:17 +0530
commit9b4553c080b5a25d4506ed463fce6478ebdc34e9 (patch)
treeba09b3cdd45614b03666fd783dd10241b335ad39 /sdm/libs/hwc2/hwc_buffer_allocator.cpp
parentf41e093f93f01a6e7156f15aa8695e36741043be (diff)
hwc2 : Validate allocated buffer before access.
Change-Id: Icb4173576cddc80c1bade67042f34ffbd87b9c44 CRs-Fixed: 2542989
Diffstat (limited to 'sdm/libs/hwc2/hwc_buffer_allocator.cpp')
-rw-r--r--sdm/libs/hwc2/hwc_buffer_allocator.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/sdm/libs/hwc2/hwc_buffer_allocator.cpp b/sdm/libs/hwc2/hwc_buffer_allocator.cpp
index 3ea5a61c..70859018 100644
--- a/sdm/libs/hwc2/hwc_buffer_allocator.cpp
+++ b/sdm/libs/hwc2/hwc_buffer_allocator.cpp
@@ -125,6 +125,9 @@ DisplayError HWCBufferAllocator::AllocateBuffer(BufferInfo *buffer_info) {
auto descriptor = BufferDescriptor();
mapper_V3_->createDescriptor(descriptor_info, [&](const auto &_error, const auto &_descriptor) {
hidl_err = _error;
+ if (hidl_err != MapperV3Error::NONE) {
+ return;
+ }
descriptor = _descriptor;
});
@@ -138,6 +141,9 @@ DisplayError HWCBufferAllocator::AllocateBuffer(BufferInfo *buffer_info) {
allocator_V3_->allocate(descriptor, 1,
[&](const auto &_error, const auto &_stride, const auto &_buffers) {
hidl_err = _error;
+ if (hidl_err != MapperV3Error::NONE) {
+ return;
+ }
raw_handle = _buffers[0];
});
@@ -148,6 +154,9 @@ DisplayError HWCBufferAllocator::AllocateBuffer(BufferInfo *buffer_info) {
mapper_V3_->importBuffer(raw_handle, [&](const auto &_error, const auto &_buffer) {
hidl_err = _error;
+ if (hidl_err != MapperV3Error::NONE) {
+ return;
+ }
buf = static_cast<const native_handle_t *>(_buffer);
});
@@ -169,6 +178,9 @@ DisplayError HWCBufferAllocator::AllocateBuffer(BufferInfo *buffer_info) {
auto descriptor = BufferDescriptor();
mapper_V2_->createDescriptor(descriptor_info, [&](const auto &_error, const auto &_descriptor) {
hidl_err = _error;
+ if (hidl_err != Error::NONE) {
+ return;
+ }
descriptor = _descriptor;
});
@@ -182,6 +194,9 @@ DisplayError HWCBufferAllocator::AllocateBuffer(BufferInfo *buffer_info) {
allocator_V2_->allocate(descriptor, 1,
[&](const auto &_error, const auto &_stride, const auto &_buffers) {
hidl_err = _error;
+ if (hidl_err != Error::NONE) {
+ return;
+ }
raw_handle = _buffers[0];
});
@@ -192,6 +207,9 @@ DisplayError HWCBufferAllocator::AllocateBuffer(BufferInfo *buffer_info) {
mapper_V2_->importBuffer(raw_handle, [&](const auto &_error, const auto &_buffer) {
hidl_err = _error;
+ if (hidl_err != Error::NONE) {
+ return;
+ }
buf = static_cast<const native_handle_t *>(_buffer);
});