From ed2ebe4b3d9b56bba90c0be8258701c40d12d26c Mon Sep 17 00:00:00 2001 From: Emilian Peev Date: Tue, 25 Sep 2018 16:59:09 +0100 Subject: [PATCH] Camera: Avoid flushing uninitialized devices Depending on timing a race is possible between two binder threads that will eventually try to disconnect the camera device. The first is a regular disconnect call and the second a binderDied notification in case the connection terminates before disconnect is able to complete. Avoid possible instabilities and skip flushing in case the device is no longer initialized. Bug: 116514106 Test: Camera CTS Change-Id: I1a958b2f80d872de89275555e83ac32576cc6792 --- services/camera/libcameraservice/device3/Camera3Device.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index 1bc5d33ca7..786fd7f3b9 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -2014,6 +2014,13 @@ status_t Camera3Device::flush(int64_t *frameNumber) { { Mutex::Autolock l(mLock); + + // b/116514106 "disconnect()" can get called twice for the same device. The + // camera device will not be initialized during the second run. + if (mStatus == STATUS_UNINITIALIZED) { + return OK; + } + mRequestThread->clear(/*out*/frameNumber); }