From 3f01ccf24b5866b23ca37bcee9e92a648363e4e1 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Thu, 18 Jun 2020 18:46:02 +0900 Subject: v4l2: v4l2_camera_proxy: Don't allow buffers to be freed if still mmaped 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 Reviewed-by: Laurent Pinchart --- src/v4l2/v4l2_camera_proxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/v4l2') diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index e54df4e6..d0a12bc3 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; -- cgit v1.2.1