From 616561634f2be37ed2cca6b73b706edb9b671785 Mon Sep 17 00:00:00 2001 From: Danny Wood Date: Thu, 4 Jul 2019 18:39:17 +0100 Subject: [PATCH] libdisplay: backport acquireFenceFd close check from SM-N935S blob to stop potential Fd leak Change-Id: I6459575717a03ae8522e4d083edf0aad49724092 --- libdisplay/ExynosOverlayDisplay.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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; } -- 2.20.1