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: d372aaa10d ("pipeline: raspberrypi: Simplify RPiCameraData::clearIncompleteRequests()")
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Naushir Patuck 2021-07-21 10:28:00 +01:00 committed by Laurent Pinchart
parent f573198d3e
commit e87fb20f8f

View file

@ -1520,8 +1520,14 @@ void RPiCameraData::clearIncompleteRequests()
for (auto &b : request->buffers()) { for (auto &b : request->buffers()) {
FrameBuffer *buffer = b.second; 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); pipe_->completeRequest(request);