Merge "sdm: handle power on during TUITransitionEnd" 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;
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index a20ac1f..54996f2 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -1327,6 +1327,13 @@
     } else {
       DLOGE("Prepare failed: %d", error);
     }
+    // Clear fences
+    DLOGI("Clearing fences on input layers on display %d-%d", display_id_, display_type_);
+    for (auto &layer : layer_stack->layers) {
+      layer->input_buffer.release_fence = nullptr;
+    }
+    layer_stack->retire_fence = nullptr;
+
     return error;
   }