[libcamera-devel,v4,20/22] v4l2: v4l2_camera_proxy: Don't allow buffers to be freed if still mmaped

Message ID 20200624145256.48266-21-paul.elder@ideasonboard.com
State Accepted
Headers show
Series
  • Support v4l2-compliance
Related show

Commit Message

Paul Elder June 24, 2020, 2:52 p.m. UTC
In VIDIOC_REQBUFS with count = 0, if the buffers are still mmaped, they
should not be allowed to be freed. Add a check for this.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---
Changes in v4:
- add todo to support buffer orphaning

No change in v3

New in v2
- split from "Fix v4l2-compliance streaming tests"
---
 src/v4l2/v4l2_camera_proxy.cpp | 4 ++++
 1 file changed, 4 insertions(+)

Patch

diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 2dbeef3..d5c146f 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -470,6 +470,10 @@  int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf
 	memset(arg->reserved, 0, sizeof(arg->reserved));
 
 	if (arg->count == 0) {
+		/* \todo Add buffer orphaning support */
+		if (!mmaps_.empty())
+			return -EBUSY;
+
 		if (vcam_->isRunning())
 			return -EBUSY;