[libcamera-devel] [PATCH 1/5] android: camera_device: Fix crash in calling CameraDevice::close()
Jacopo Mondi
jacopo at jmondi.org
Mon Sep 6 16:01:48 CEST 2021
From: Hirokazu Honda <hiroh at chromium.org>
The problem is happening because we seem to add a CameraStream
associated buffer (depending on the CameraStream::Type) to the Request,
in CameraDevice::processCaptureRequest().
However, when the camera stops, all the current buffers are marked with
FrameMetadata::FrameCancelled and proceed to completion. But the buffer
associated with the CameraStream (that was previously added to the
request) has now been cleared out with a part of streams_.clear(), even
before the camera stop() has been invoked. Any access to those request
buffers after they have been cleared, will result in a crash.
Signed-off-by: Hirokazu Honda <hiroh at chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain at ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_device.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 8ca76719a50f..fda77db4540c 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -423,8 +423,6 @@ int CameraDevice::open(const hw_module_t *hardwareModule)
void CameraDevice::close()
{
- streams_.clear();
-
stop();
camera_->release();
@@ -457,6 +455,8 @@ void CameraDevice::stop()
camera_->stop();
descriptors_.clear();
+ streams_.clear();
+
state_ = State::Stopped;
}
--
2.32.0
More information about the libcamera-devel
mailing list