[FFmpeg-devel] [PATCH 2/2] avcodec/v4l2: fix segmentation fault on codec exit

Jorge Ramirez-Ortiz jorge.ramirez-ortiz at linaro.org
Fri Oct 6 10:52:02 EEST 2017

It occurs when the codec is closed while buffer references still
exist. This is a regression from the original patchset where support
for this use-case was implemented.

The regression occurred while cleaning the code for the last patchset
(decoding was tested only with ffplay which disposes of the buffer
straightaway hence the feature went in broken/untested)
 libavcodec/v4l2_m2m.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
index bd96a6d..5e85bcb 100644
--- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c
@@ -331,8 +331,10 @@ int ff_v4l2_m2m_codec_end(AVCodecContext *avctx)
-    if (atomic_load(&s->refcount))
-        av_log(avctx, AV_LOG_ERROR, "ff_v4l2m2m_codec_end leaving pending buffers\n");
+    if (atomic_load(&s->refcount)) {
+        av_log(avctx, AV_LOG_DEBUG, "ff_v4l2m2m_codec_end leaving pending buffers\n");
+        return 0;
+    }

More information about the ffmpeg-devel mailing list