@@ -1384,6 +1384,7 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,
{
struct v4l2_exportbuffer expbuf = {};
int ret;
+ FileDescriptor fd;
expbuf.type = bufferType_;
expbuf.index = index;
@@ -1397,7 +1398,14 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,
return FileDescriptor();
}
- return FileDescriptor(std::move(expbuf.fd));
+ fd = FileDescriptor(std::move(expbuf.fd));
+ /*
+ * since FileDesciptor makes a dup of the fd, original fd must be
+ * closed or else driver considers it as an orphaned buffer (due to
+ * additional buffer refcount) thus causing a frame buffer leak
+ */
+ ::close(expbuf.fd);
+ return fd;
}
/**