From: Danny Wood Date: Thu, 4 Jul 2019 17:39:17 +0000 (+0100) Subject: libdisplay: backport acquireFenceFd close check from SM-N935S blob to stop potential... X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=181817b632c63ba05c798f0f88ec3304a80e721f;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_exynos.git libdisplay: backport acquireFenceFd close check from SM-N935S blob to stop potential Fd leak Change-Id: I6459575717a03ae8522e4d083edf0aad49724092 --- diff --git a/libdisplay/ExynosOverlayDisplay.cpp b/libdisplay/ExynosOverlayDisplay.cpp index 2f12a25..33335ec 100644 --- a/libdisplay/ExynosOverlayDisplay.cpp +++ b/libdisplay/ExynosOverlayDisplay.cpp @@ -858,6 +858,18 @@ int ExynosOverlayDisplay::set(hwc_display_contents_1_t* contents) mHwc->hwc_ctrl.max_num_ovly = mAllowedOverlays; + for (size_t i = 0; i < contents->numHwLayers; i++) { + hwc_layer_1_t &layer = contents->hwLayers[i]; + /* If Fb is not needed and this is a HWC buffer (function reverse engineered from S7 libexynosdisplay.so) */ + if(!mFbNeeded && layer.compositionType == HWC_FRAMEBUFFER_TARGET) { + /* Close the acquire fence Fd if it is valid */ + if(layer.acquireFenceFd >= 0) { + close(layer.acquireFenceFd); + layer.acquireFenceFd = -1; + } + } + } + return err; }