drm_hwcomposer: HWC2: Handle bad layer_handle
HWC2 can issue a command with an incorrect layer handle. Making sure a such
error is caught with the expected HWC2 error code BadLayer
This can be verified with the VTS test:
* GraphicsComposerHidlTest.DestroyLayerBadLayerError
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index 95c93de..814d8f7 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -273,6 +273,9 @@
HWC2::Error DrmHwcTwo::HwcDisplay::DestroyLayer(hwc2_layer_t layer) {
supported(__func__);
+ if (!get_layer(layer))
+ return HWC2::Error::BadLayer;
+
layers_.erase(layer);
return HWC2::Error::None;
}