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
gugelfrei
Emilian Peev 6 years ago
parent 6976bebc9d
commit 2843c36c64

@ -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();
}

Loading…
Cancel
Save