From e39f046f660a6d0954d81b92bd183e7ba679fa56 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Mon, 30 Jan 2023 18:02:43 +0000 Subject: libcamera: camera: Ensure queued requests are invalid Invalid, or not correctly reset requests can cause undefined behaviour in the pipeline handlers due to unexpected request state. If the status has not been reset to Request::RequestPending, it is either not new, or has not been correctly procesed through Request::reuse(). This can be caught early by validating the status of the request when it is queued to a camera. Reject invalid requests before processing them in the pipeline handlers. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Paul Elder Signed-off-by: Kieran Bingham --- src/libcamera/camera.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 0da167a7..99683e49 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -1126,6 +1126,11 @@ int Camera::queueRequest(Request *request) return -EXDEV; } + if (request->status() != Request::RequestPending) { + LOG(Camera, Error) << request->toString() << " is not valid"; + return -EINVAL; + } + /* * The camera state may change until the end of the function. No locking * is however needed as PipelineHandler::queueRequest() will handle -- cgit v1.2.1