[libcamera-devel] [PATCH 1/2] libcamera: v4l2_device: Close Plane dmabuf fd

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Mar 5 00:25:29 CET 2019


When constructing a Plane, the exported buffer provides a dmabuf handle which
is set to the Plane object.

This action duplicates the handle for internal storage, and the original fd is
not used and needs to be closed.

Close the handle, ensuring that the resources can be correctly managed.

Fixes: 771befc6dc0e ("libcamera: v4l2_device: Request buffers from the device")
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 src/libcamera/v4l2_device.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 0cd9f4b8e178..a88a5f5ff036 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -676,6 +676,7 @@ int V4L2Device::createPlane(Buffer *buffer, unsigned int planeIndex,
 	buffer->planes().emplace_back();
 	Plane &plane = buffer->planes().back();
 	plane.setDmabuf(expbuf.fd, length);
+	::close(expbuf.fd);
 
 	return 0;
 }
-- 
2.19.1



More information about the libcamera-devel mailing list