libcamera: v4l2_videodevice: Fix dangling file descriptor
The FileDescriptor constructor used in V4L2VideoDevice::exportDmabufFd() creates a duplicate of the fd to store in the object. The original fd returned by the VIDIOC_EXPBUF ioctl was never closed, and left dangling. This would cause out of memory conditions if the camera stream was repeatedly started and stopped. This change closes the original fd explicitly, fixing the leak. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
aa7e7175c7
commit
353fc4c223
1 changed files with 8 additions and 1 deletions
|
@ -1276,7 +1276,14 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,
|
|||
return FileDescriptor();
|
||||
}
|
||||
|
||||
return FileDescriptor(expbuf.fd);
|
||||
FileDescriptor fd(expbuf.fd);
|
||||
/*
|
||||
* FileDescriptor takes a duplicate of fd, so we must close the
|
||||
* original here, otherwise it will be left dangling.
|
||||
*/
|
||||
::close(expbuf.fd);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue