[libcamera-devel] [PATCH] android: camera_device: Check capture_request validity

Jacopo Mondi jacopo at jmondi.org
Tue Dec 1 17:14:45 CET 2020


Make sure the 'camera3_capture_request_t *' provided to
CameraDevice::processCaptureRequest() is valid before attempting to
access it.

Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
This patch fixes cros_camera_test:
Camera3FrameTest/Camera3InvalidRequestTest.NullOrUnconfiguredRequest/*
---

 src/android/camera_device.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 4eb05df0fdc2..3c8205a095ae 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1398,6 +1398,11 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer

 int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)
 {
+	if (!camera3Request) {
+		LOG(HAL, Error) << "Invalid capture request";
+		return -EINVAL;
+	}
+
 	if (!camera3Request->num_output_buffers) {
 		LOG(HAL, Error) << "No output buffers provided";
 		return -EINVAL;
--
2.29.1



More information about the libcamera-devel mailing list