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 <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Kieran Bingham 2023-01-30 18:02:43 +00:00
parent d9371444c4
commit e39f046f66

View file

@ -1126,6 +1126,11 @@ int Camera::queueRequest(Request *request)
return -EXDEV; 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 * The camera state may change until the end of the function. No locking
* is however needed as PipelineHandler::queueRequest() will handle * is however needed as PipelineHandler::queueRequest() will handle