From 2843c36c64a050adeb3a6c187aed611d991b97cd Mon Sep 17 00:00:00 2001 From: Emilian Peev Date: Wed, 26 Sep 2018 08:49:40 +0100 Subject: [PATCH] Camera: Limit the scope 'mTrackerLock' within 'disconnectImpl' 'disconnectImpl' holds 'mTrackerLock' for its entire scope. This is not needed and could lead to deadlocks in case the request thread encounters errors and tries to clean up any failed requests. In this scenario the request thread will already hold 'mInflightLock' and then try to acquire 'mTrackerLock' as well. The 'disconnectImpl' context will acquire 'mTrackerLock' first and at some later point try to get 'mInflightLock' which will end up in a deadlock. To avoid this, limit the scope of 'mTrackerLock' within 'disconnectImpl'. The lock purpose is to protect other threads from accessing invalid 'mStatusTracker' instances and must not introduce side effects. Bug: 115784704 Test: Camera CTS, Manual test Change-Id: I96b039cb454e0c185ecdf0c8072a9494233c1169 --- services/camera/libcameraservice/device3/Camera3Device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index 1bc5d33ca7..48be4448df 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -281,7 +281,6 @@ status_t Camera3Device::disconnect() { status_t Camera3Device::disconnectImpl() { ATRACE_CALL(); Mutex::Autolock il(mInterfaceLock); - Mutex::Autolock stLock(mTrackerLock); ALOGI("%s: E", __FUNCTION__); @@ -346,6 +345,7 @@ status_t Camera3Device::disconnectImpl() { { Mutex::Autolock l(mLock); mRequestThread.clear(); + Mutex::Autolock stLock(mTrackerLock); mStatusTracker.clear(); interface = mInterface.get(); }