Skip to content

Fix leak of dmabuf fds when VAImage is destroyed before releasing its buffer handler

Val Doroshchuk requested to merge valbok/gstreamer-vaapi:master into master

Since gst_vaapi_surface_get_dma_buf_handle() creates proxy buffer object with buffer id from VAImage, and acquires (via vaAcquireBufferHandle) its fd.

And calling gst_vaapi_buffer_proxy_release_data() from gst_vaapi_dmabuf_memory_new() will free VAImage and thus its internal buffer.

But its dmabuf fd still remains opened.

This buffer handle must be released (via vaReleaseBufferHandle) before calling vaDestroyImage()

Since vaAcquireBufferHandle() (acquiring the fd) is called together with gst_vaapi_buffer_proxy_new_from_object() and thus proxy->va_buf != VA_INVALID_ID,

suggesting to call gst_vaapi_buffer_proxy_release_handle() when user's data is released.

It will check proxy->va_buf and make sure that vaReleaseBufferHandle() will be called only after vaAcquireBufferHandle().


Edited by Tim-Philipp Müller

Merge request reports