[v1,7/9] v4l2: v4l2_camera: Always clear pending requests
diff mbox series

Message ID 20261201083805.496809-8-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • v4l2: request-buffer split preparation
Related show

Commit Message

Barnabás Pőcze Dec. 1, 2026, 8:38 a.m. UTC
Clear the list of pending requests regardless whether the camera is running
or not. The list should only contain entries when `!isRunning_`, in which
case it was not cleared previously.

Consider the following scenario:

  * STREAMOFF
  * QBUF(10)
  * STREAMOFF
  // at this point buffer 10 should be dequeued;
  // but `pendingRequests_` would still have the request
  // that was added due to QBUF
  * QBUF(10)
  // `pendingRequests_` would have the same requests twice
  * STREAMON
  // the same request would be tried to be queued twice

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/v4l2/v4l2_camera.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp
index 71df214e58..c7f227ee09 100644
--- a/src/v4l2/v4l2_camera.cpp
+++ b/src/v4l2/v4l2_camera.cpp
@@ -227,6 +227,8 @@  int V4L2Camera::streamOn()
 
 int V4L2Camera::streamOff()
 {
+	pendingRequests_.clear();
+
 	if (!isRunning_) {
 		for (std::unique_ptr<Request> &req : requestPool_)
 			req->reuse();
@@ -234,8 +236,6 @@  int V4L2Camera::streamOff()
 		return 0;
 	}
 
-	pendingRequests_.clear();
-
 	int ret = camera_->stop();
 	if (ret < 0)
 		return ret == -EACCES ? -EBUSY : ret;