Merge "sdm: Fix output fences on prepare failure." into display.lnx.9.0.r1-rel
diff --git a/composer/hwc_layers.cpp b/composer/hwc_layers.cpp
index 842269f..b6bdb21 100644
--- a/composer/hwc_layers.cpp
+++ b/composer/hwc_layers.cpp
@@ -1079,6 +1079,9 @@
   if (gralloc::GetMetaDataValue(handle, qtigralloc::MetadataType_LinearFormat.value,
                                 &linear_format) == gralloc::Error::NONE) {
     layer_buffer->format = GetSDMFormat(INT32(linear_format), 0);
+    if (layer_buffer->format == kFormatInvalid) {
+      return kErrorNotSupported;
+    }
   }
 
   if ((interlace != layer_buffer->flags.interlace) || (frame_rate != layer->frame_rate)) {
@@ -1099,6 +1102,9 @@
       gralloc::Error::NONE) {
     // Only copy top layer for now as only top field for interlaced is used
     GetUBWCStatsFromMetaData(&cr_stats[0], &(layer_buffer->ubwc_crstats[0]));
+    if (cr_stats[0].version < 0 || cr_stats[0].version >= UBWC_MAX_VERSION) {
+      return kErrorNotSupported;
+    }
   }
 
   uint32_t single_buffer = 0;