Gralloc: unmap metadata and reset mapped pointer in alloc
Use setMetaDataAndUnmap(..) during alloc to ensure allocating
process does not duplicate invalid base address of metadata
in case native_handle is cloned without importing.
Change-Id: I0481ad8d59950256723871a089aeb3d143afac5a
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp
index 61e31d6..cd36c13 100644
--- a/gralloc/gr_buf_mgr.cpp
+++ b/gralloc/gr_buf_mgr.cpp
@@ -329,11 +329,11 @@
hnd->layer_count = layer_count;
// set default csc as 709, but for video(yuv) its 601L
ColorSpace_t colorSpace = (buffer_type == BUFFER_TYPE_VIDEO) ? ITU_R_601 : ITU_R_709;
- setMetaData(hnd, UPDATE_COLOR_SPACE, reinterpret_cast<void *>(&colorSpace));
+ setMetaDataAndUnmap(hnd, UPDATE_COLOR_SPACE, reinterpret_cast<void *>(&colorSpace));
bool use_adreno_for_size = CanUseAdrenoForSize(buffer_type, usage);
if (use_adreno_for_size) {
- setMetaData(hnd, SET_GRAPHICS_METADATA, reinterpret_cast<void *>(&graphics_metadata));
+ setMetaDataAndUnmap(hnd, SET_GRAPHICS_METADATA, reinterpret_cast<void *>(&graphics_metadata));
}
*handle = hnd;