From 542b068e322f90e7e6689daddddc493363d0b549 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Wed, 3 Aug 2016 15:28:43 -0700 Subject: [PATCH] surfaceflinger: Fix uninitialized variable * And don't try to reinit the lib after a failure. Change-Id: Ic055a48670ed8cf01e27b16c5d4ddf214db53d20 --- services/surfaceflinger/LayerBlur.cpp | 9 ++++++++- services/surfaceflinger/LayerBlur.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/services/surfaceflinger/LayerBlur.cpp b/services/surfaceflinger/LayerBlur.cpp index a49ff39d6..93f548f0a 100644 --- a/services/surfaceflinger/LayerBlur.cpp +++ b/services/surfaceflinger/LayerBlur.cpp @@ -404,6 +404,7 @@ void LayerBlur::ensureFbo(FBO& fbo, int width, int height, int textureName) { // --------------------------------------------------------------------------- void* LayerBlur::BlurImpl::sLibHandle = NULL; +bool LayerBlur::BlurImpl::sUnsupported = false; LayerBlur::BlurImpl::initBlurTokenFn LayerBlur::BlurImpl::initBlurToken = NULL; LayerBlur::BlurImpl::releaseBlurTokenFn LayerBlur::BlurImpl::releaseBlurToken = NULL; @@ -421,8 +422,13 @@ status_t LayerBlur::BlurImpl::initBlurImpl() { if (sLibHandle != NULL) { return OK; } + if (sUnsupported) { + return NO_INIT; + } + sLibHandle = dlopen("libuiblur.so", RTLD_NOW); if (sLibHandle == NULL) { + sUnsupported = true; return NO_INIT; } @@ -444,13 +450,14 @@ status_t LayerBlur::BlurImpl::initBlurImpl() { if (!initBlurToken || !releaseBlurToken || !doBlur) { ALOGE("dlsym failed for blur impl!: %s", dlerror()); closeBlurImpl(); + sUnsupported = true; return NO_INIT; } return OK; } -LayerBlur::BlurImpl::BlurImpl() { +LayerBlur::BlurImpl::BlurImpl() : mToken(NULL) { Mutex::Autolock _l(sLock); if (initBlurImpl() == OK) { mToken = initBlurToken(); diff --git a/services/surfaceflinger/LayerBlur.h b/services/surfaceflinger/LayerBlur.h index 63138c4c2..bd37ad37d 100644 --- a/services/surfaceflinger/LayerBlur.h +++ b/services/surfaceflinger/LayerBlur.h @@ -68,6 +68,7 @@ private: static status_t initBlurImpl(); static void closeBlurImpl(); static void* sLibHandle; + static bool sUnsupported; typedef void* (*initBlurTokenFn)(); typedef void* (*releaseBlurTokenFn)(void*);