Merge "Camera: fix status tracker race condition"
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index e8b9b20..0c83ed0 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -2326,7 +2326,11 @@
if (res < 0) return res;
if (mInFlightMap.size() == 1) {
- mStatusTracker->markComponentActive(mInFlightStatusId);
+ // hold mLock to prevent race with disconnect
+ Mutex::Autolock l(mLock);
+ if (mStatusTracker != nullptr) {
+ mStatusTracker->markComponentActive(mInFlightStatusId);
+ }
}
return OK;
@@ -2353,7 +2357,11 @@
// Indicate idle inFlightMap to the status tracker
if (mInFlightMap.size() == 0) {
- mStatusTracker->markComponentIdle(mInFlightStatusId, Fence::NO_FENCE);
+ // hold mLock to prevent race with disconnect
+ Mutex::Autolock l(mLock);
+ if (mStatusTracker != nullptr) {
+ mStatusTracker->markComponentIdle(mInFlightStatusId, Fence::NO_FENCE);
+ }
}
}