sdm: fix null pointer dereference and vector initialization.
Change-Id: I25bb8daa6b49223a443a31d1ae17560ed6fca486
Signed-off-by: Pramodh Kumar Mukunda <pkmuku@codeaurora.org>
diff --git a/libgralloc1/gr_utils.cpp b/libgralloc1/gr_utils.cpp
index b3056e1..560bb08 100644
--- a/libgralloc1/gr_utils.cpp
+++ b/libgralloc1/gr_utils.cpp
@@ -509,7 +509,9 @@
// Query GPU for UBWC only if buffer is intended to be used by GPU.
if ((cons_usage & GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE) ||
(prod_usage & GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET)) {
- enable = AdrenoMemInfo::GetInstance()->IsUBWCSupportedByGPU(format);
+ if (AdrenoMemInfo::GetInstance()) {
+ enable = AdrenoMemInfo::GetInstance()->IsUBWCSupportedByGPU(format);
+ }
}
// Allow UBWC, only if CPU usage flags are not set
@@ -675,8 +677,10 @@
int tile = ubwc_enabled;
if (IsUncompressedRGBFormat(format)) {
- AdrenoMemInfo::GetInstance()->AlignUnCompressedRGB(width, height, format, tile, alignedw,
- alignedh);
+ if (AdrenoMemInfo::GetInstance()) {
+ AdrenoMemInfo::GetInstance()->AlignUnCompressedRGB(width, height, format, tile, alignedw,
+ alignedh);
+ }
return;
}
@@ -686,7 +690,9 @@
}
if (IsCompressedRGBFormat(format)) {
- AdrenoMemInfo::GetInstance()->AlignCompressedRGB(width, height, format, alignedw, alignedh);
+ if (AdrenoMemInfo::GetInstance()) {
+ AdrenoMemInfo::GetInstance()->AlignCompressedRGB(width, height, format, alignedw, alignedh);
+ }
return;
}
@@ -698,6 +704,9 @@
switch (format) {
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ if (AdrenoMemInfo::GetInstance() == nullptr) {
+ return;
+ }
alignment = AdrenoMemInfo::GetInstance()->GetGpuPixelAlignment();
aligned_w = ALIGN(width, alignment);
break;