GNOME Bugzilla – Bug 745443
v4l2: fix fd leak in dma_buf import mode
Last modified: 2015-03-02 20:41:20 UTC
The attached patch fixes an fd leak when e.g. v4l2src io-mode=dmabuf-import is used. The reason behind this is that we were re-assigning the parent memory group fd with a new fd where the old one was not closed first.
Created attachment 298270 [details] [review] v4l2allocator: fix fd leak in DMABUF import mode BTW, I want to push this one to 1.4 branch too. Thanks.
Review of attachment 298270 [details] [review]: You are missing bug link in your commit message.
Created attachment 298299 [details] [review] v4l2allocator: fix fd leak in DMABUF import mode The patch was created before the report and the new "attachment" feature was used during the creation of the said bug. :)
Review of attachment 298270 [details] [review]: This patch is wrong. The code dup() the FD and you close it right away. Then you give the driver a closed FD ...
Review of attachment 298299 [details] [review]: Same.
gst_v4l2_allocator_clear_dmabufin() is supposed to be called before importing again.
(In reply to Nicolas Dufresne (stormer) from comment #4) > Review of attachment 298270 [details] [review] [review]: > > This patch is wrong. The code dup() the FD and you close it right away. Then > you give the driver a closed FD ... No, please read again, with the context.
(In reply to Nicolas Dufresne (stormer) from comment #6) > gst_v4l2_allocator_clear_dmabufin() is supposed to be called before > importing again. Should we also gst_v4l2_allocator_clear_userptr (); while we are it for USERPTR as well?
We do clear on DQ. Which means we close the FD when we get back the buffer from the driver. Closing an FD in import make no sense, the buffer should have been cleared. Your bug is elsewhere. Can you provide me with a way to reproduce. Should be reproducible with vivid imho.
Created attachment 298316 [details] [review] v4l2allocator: fix fd leak in DMABUF import mode
Thanks. Master: commit 8cd40e77b70dae2a7b76f41c47a753a526d4da49 1.4 commit fe3cdccbf2922053fe3774875e315d5ed9a66a72 Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com> Date: Mon Mar 2 12:04:00 2015 +0100 v4l2allocator: fix fd leak in DMABUF import mode. Ensure gst_v4l2_buffer_pool_release_buffer() releases the associated GstV4l2MemoryGroup. In particular, this allows for closing the DMABUF handles prior to instantiating new ones. https://bugzilla.gnome.org/show_bug.cgi?id=745443