From 77c052f0e89a622fa0ea723f3d477befb3817469 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 24 Jul 2018 12:07:22 -0400 Subject: [PATCH] v4l2bufferpool: Only queue buffer if preparation worked The preparation code imports the buffer, doing bunch of validation. Only queue the buffer in the driver if the importation worked. This way we don't rely on the driver to validate. https://bugzilla.gnome.org/show_bug.cgi?id=583890 --- sys/v4l2/gstv4l2bufferpool.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 9eba369ee4..ff08a2615a 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -1414,11 +1414,14 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer) { GstV4l2MemoryGroup *group; if (gst_v4l2_is_buffer_valid (buffer, &group)) { + GstFlowReturn ret = GST_FLOW_OK; + gst_v4l2_allocator_reset_group (pool->vallocator, group); /* queue back in the device */ if (pool->other_pool) - gst_v4l2_buffer_pool_prepare_buffer (pool, buffer, NULL); - if (gst_v4l2_buffer_pool_qbuf (pool, buffer, group) != GST_FLOW_OK) + ret = gst_v4l2_buffer_pool_prepare_buffer (pool, buffer, NULL); + if (ret != GST_FLOW_OK || + gst_v4l2_buffer_pool_qbuf (pool, buffer, group) != GST_FLOW_OK) pclass->release_buffer (bpool, buffer); } else { /* Simply release invalide/modified buffer, the allocator will