summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKobi Cohen Arazi <kobic@codeaurora.org>2011-04-15 10:38:33 -0700
committerKobi Cohen Arazi <kobic@codeaurora.org>2011-04-15 10:38:33 -0700
commit8ecc90d00df9ca90dfbf505daa051eb2a05a14de (patch)
treec91635f737ccf9f2387ff63c64b53a3140e6b8e6
parent08d9d9a46250c4fad66e9b637e8898a3524c4286 (diff)
downloadframeworks_base-8ecc90d00df9ca90dfbf505daa051eb2a05a14de.zip
frameworks_base-8ecc90d00df9ca90dfbf505daa051eb2a05a14de.tar.gz
frameworks_base-8ecc90d00df9ca90dfbf505daa051eb2a05a14de.tar.bz2
Add lock before calling initEglImage
Without that lock, there is a chance of race condition where while composing a specific index, requestBuf with the same index can be executed and touch the same data that is being used in initEglImage. (e.g. dirty flag in texture)
-rw-r--r--services/surfaceflinger/Layer.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index c9dcef3..dfee803 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -874,8 +874,16 @@ status_t Layer::BufferManager::initEglImage(EGLDisplay dpy,
ssize_t index = mActiveBuffer;
if (index >= 0) {
if (!mFailover) {
- Image& texture(mBufferData[index].texture);
- err = mTextureManager.initEglImage(&texture, dpy, buffer);
+ {
+ // Without that lock, there is a chance of race condition
+ // where while composing a specific index, requestBuf
+ // with the same index can be executed and touch the same data
+ // that is being used in initEglImage.
+ // (e.g. dirty flag in texture)
+ Mutex::Autolock _l(mLock);
+ Image& texture(mBufferData[index].texture);
+ err = mTextureManager.initEglImage(&texture, dpy, buffer);
+ }
// if EGLImage fails, we switch to regular texture mode, and we
// free all resources associated with using EGLImages.
if (err == NO_ERROR) {