From 2cf0c87511caccabdea39a9e65aef10bf5f48c19 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Tue, 2 Mar 2021 12:23:40 +0000 Subject: libcamera: Request: validate state on complete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Requests should only be completed from the RequestPending state. Requests which are completed from the RequestCancelled, or RequestComplete state, will indicate that a double-complete has been called on the Request, or that it has been used internally after it has been given back to the application. Ensure that this can be caught early if it occurs by enforcing the state required with an assert. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Niklas Söderlund Signed-off-by: Kieran Bingham --- src/libcamera/request.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/libcamera/request.cpp') diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index e561ce1d..24c3694d 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -262,7 +262,9 @@ FrameBuffer *Request::findBuffer(const Stream *stream) const */ void Request::complete() { + ASSERT(status_ == RequestPending); ASSERT(!hasPendingBuffers()); + status_ = cancelled_ ? RequestCancelled : RequestComplete; LOG(Request, Debug) -- cgit v1.2.1