[FFmpeg-devel] [RFC] v4l2_m2m: Fix races around freeing data on close

Jorge Ramirez jorge.ramirez-ortiz at linaro.org
Thu Oct 19 10:28:51 EEST 2017

On 10/19/2017 02:10 AM, Mark Thompson wrote:
> Refcount all of the context information.
> ---
> As discussed in the other thread, something like this.  We move most of the context into a refcounted buffer and AVCodecContext.priv_data is left as a stub holding a reference to it.

um, ok ... please could you send a patch so I can apply it? I see 
several problems in v4l2_free_buffer.

To sum up the RFC, instead of using private_data to place the codec's 
context, it uses private data to place a _pointer_ to an allocated codec 
context "just" so it wont be deallocated after the codec is closed 
(codec close frees the private_data)

use private_data to hold the codec context is a cleaner/simpler approach.

- the codec requests private_data with a size (sizeof(type))
- the code explicitly informs the API whether all memory will be 
released on close or it will preserve it.

More information about the ffmpeg-devel mailing list