Fix crash issue arising out of multiple hdmi connect/disconnects
Acquire mExtLock before proceeding further in
hwc_prepare_external to prevent crashes arising out
of updating ctx variables from two different
threads(composition and uevent threads)
Change-Id: I0f18c41b117f18aeb25572b53ef6eba3638bb826
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 9bf0c45..7bfbf06 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -158,7 +158,9 @@
static int hwc_prepare_external(hwc_composer_device_1 *dev,
hwc_display_contents_1_t *list, int dpy) {
+
hwc_context_t* ctx = (hwc_context_t*)(dev);
+ Locker::Autolock _l(ctx->mExtLock);
if (LIKELY(list && list->numHwLayers > 1) &&
ctx->dpyAttr[dpy].isActive &&
@@ -398,7 +400,7 @@
{
ATRACE_CALL();
int ret = 0;
- Locker::Autolock _l(ctx->mExtSetLock);
+ Locker::Autolock _l(ctx->mExtLock);
if (LIKELY(list) && ctx->dpyAttr[dpy].isActive &&
!ctx->dpyAttr[dpy].isPause &&
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index eb525a6..b314317 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -148,7 +148,7 @@
}else if(!strncmp(s1,"wfd",strlen(s1))) {
ctx->mExtDisplay->teardownWFDDisplay();
}
- Locker::Autolock _l(ctx->mExtSetLock);
+ Locker::Autolock _l(ctx->mExtLock);
clear(ctx, dpy);
ALOGD("%s sending hotplug: connected = %d and dpy:%d",
__FUNCTION__, connected, dpy);
@@ -170,7 +170,7 @@
// teardown Active WFD Display
ctx->mExtDisplay->teardownWFDDisplay();
{
- Locker::Autolock _l(ctx->mExtSetLock);
+ Locker::Autolock _l(ctx->mExtLock);
clear(ctx, dpy);
//send hotplug disconnect event
ALOGD_IF(UEVENT_DEBUG, "sending hotplug: disconnect"
@@ -195,7 +195,7 @@
ALOGD("%s sending hotplug: connected = %d", __FUNCTION__,
connected);
ctx->dpyAttr[dpy].connected = true;
- Locker::Autolock _l(ctx->mExtSetLock); //hwc comp could be on
+ Locker::Autolock _l(ctx->mExtLock); //hwc comp could be on
ctx->proc->hotplug(ctx->proc, dpy, connected);
break;
}
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index e0fff77..6e95703 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -269,8 +269,8 @@
bool mSecureMode;
//Lock to prevent set from being called while blanking
mutable Locker mBlankLock;
- //Lock to protect set when detaching external disp
- mutable Locker mExtSetLock;
+ //Lock to protect prepare & set when detaching external disp
+ mutable Locker mExtLock;
//Vsync
struct vsync_state vstate;
//Drawing round when we use GPU