From e87fb20f8f5db9d54b9ca0bb0fdd8a1a9d30a8bd Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Wed, 21 Jul 2021 10:28:00 +0100 Subject: pipeline: raspberrypi: Fix a bug when clearing out Request buffers on stop When RPiCameraData::clearIncompleteRequests() clears out the request queue during a stop condition, it unconditionally calls completeBuffer() on all buffers in each request. This is wrong, as a buffer could have already been completed as part of the current request, but the request itself may not yet have completed. Fix this by checking if the buffers in the request have been completed before cancelling them. Fixes: d372aaa10ddb ("pipeline: raspberrypi: Simplify RPiCameraData::clearIncompleteRequests()") Signed-off-by: Naushir Patuck Tested-by: David Plowman Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index f821d8fe..0bab3bed 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1520,8 +1520,14 @@ void RPiCameraData::clearIncompleteRequests() for (auto &b : request->buffers()) { FrameBuffer *buffer = b.second; - buffer->cancel(); - pipe_->completeBuffer(request, buffer); + /* + * Has the buffer already been handed back to the + * request? If not, do so now. + */ + if (buffer->request()) { + buffer->cancel(); + pipe_->completeBuffer(request, buffer); + } } pipe_->completeRequest(request); -- cgit v1.2.1