@@ -43,6 +43,8 @@ Buffer::~Buffer()
* \brief Set the dmabuf file handle backing the buffer
*
* The \a fd dmabuf file handle is duplicated and stored.
+ *
+ * \return 0 on success or a negative error value otherwise.
*/
int Buffer::setDmabuf(int fd)
{
@@ -51,12 +53,19 @@ int Buffer::setDmabuf(int fd)
fd_ = -1;
}
- if (fd != -1)
- return 0;
+ if (fd < 0) {
+ LOG(Buffer, Error) << "Invalid DMABuf FD provided";
+ return -EINVAL;
+ }
fd_ = dup(fd);
- if (fd_ == -1)
- return -errno;
+ if (fd_ == -1) {
+ int ret = -errno;
+ LOG(Buffer, Error)
+ << "Failed to duplicate Dmabuf: " << strerror(-ret);
+
+ return ret;
+ }
return 0;
}
The setDmabuf validation for the input FD was incorrect. Fix this, and update the documentation and error reporting. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> --- src/libcamera/buffer.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)