From fdf70ba1ab6b412040441d0011bf4d56dae6188e Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Fri, 8 Dec 2017 14:46:02 +0100 Subject: vaapipostproc: lock ensure_filter with postproc_lock gst_vaapipostproc_ensure_filter might free the allowed_srcpad_caps and allowed_sinkpad_caps. This can race with copying these caps in gst_vaapipostproc_transform_caps and lead to segfaults. The gst_vaapipostproc_transform_caps function already locks postproc_lock before copying the caps. Make sure that calls to gst_vaapipostproc_ensure_filter also acquire this lock. --- gst/vaapi/gstvaapipostproc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c index d67cdfc4..deaf23ce 100644 --- a/gst/vaapi/gstvaapipostproc.c +++ b/gst/vaapi/gstvaapipostproc.c @@ -305,8 +305,13 @@ gst_vaapipostproc_start (GstBaseTransform * trans) ds_reset (&postproc->deinterlace_state); if (!gst_vaapi_plugin_base_open (GST_VAAPI_PLUGIN_BASE (postproc))) return FALSE; - if (!gst_vaapipostproc_ensure_filter (postproc)) + g_mutex_lock (&postproc->postproc_lock); + if (!gst_vaapipostproc_ensure_filter (postproc)) { + g_mutex_unlock (&postproc->postproc_lock); return FALSE; + } + g_mutex_unlock (&postproc->postproc_lock); + return TRUE; } @@ -1878,8 +1883,12 @@ cb_channels_init (GstVaapiPostproc * postproc) if (postproc->cb_channels) return; - if (!gst_vaapipostproc_ensure_filter (postproc)) + g_mutex_lock (&postproc->postproc_lock); + if (!gst_vaapipostproc_ensure_filter (postproc)) { + g_mutex_unlock (&postproc->postproc_lock); return; + } + g_mutex_unlock (&postproc->postproc_lock); filter_ops = postproc->filter_ops ? g_ptr_array_ref (postproc->filter_ops) : gst_vaapi_filter_get_operations (postproc->filter); -- cgit v1.2.3