Camera: Fix potentail race condition

mDistortionMappers are used in callback thread and request thread.
However, callback thread does not query before calling mDistortionMappers[mId.c_str()],
this may cause insertion to the map and mDistortionMappers.find may run at the same time.

Bug: 153506800, 153457587
Test: Camera CTS
Change-Id: I899033bacd355113fbad3e8f7ec76482aa147158
gugelfrei
Yin-Chia Yeh 4 years ago
parent b27ef83f2c
commit 7ffbd98989

@ -259,13 +259,15 @@ void sendCaptureResult(
}
// Fix up some result metadata to account for HAL-level distortion correction
status_t res =
states.distortionMappers[states.cameraId.c_str()].correctCaptureResult(
&captureResult.mMetadata);
if (res != OK) {
SET_ERR("Unable to correct capture result metadata for frame %d: %s (%d)",
frameNumber, strerror(-res), res);
return;
status_t res = OK;
auto iter = states.distortionMappers.find(states.cameraId.c_str());
if (iter != states.distortionMappers.end()) {
res = iter->second.correctCaptureResult(&captureResult.mMetadata);
if (res != OK) {
SET_ERR("Unable to correct capture result metadata for frame %d: %s (%d)",
frameNumber, strerror(-res), res);
return;
}
}
// Fix up result metadata to account for zoom ratio availabilities between

Loading…
Cancel
Save