summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tretter <m.tretter@pengutronix.de>2017-12-08 14:46:02 +0100
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2018-01-12 20:07:18 +0100
commitfdf70ba1ab6b412040441d0011bf4d56dae6188e (patch)
tree52b48527025d501fd2bb4de33917ab432e8aea98
parente540e0899421d580423f41a7bd65307923eb6a26 (diff)
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.
-rw-r--r--gst/vaapi/gstvaapipostproc.c13
1 files 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);