v4l2bufferpool: Fix race condition between qbuf and pool streamoff
authorHou Qi <qi.hou@nxp.com>
Thu, 3 Mar 2022 05:47:05 +0000 (13:47 +0800)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 7 Mar 2022 15:14:15 +0000 (15:14 +0000)
commitfa6f34d595f93a020826e3d77164551818e1b5fd
tree35288b9276f29027cd9082e695998842097a636f
parent52c0763042233f6173cc1dc77c3b9993c5184e62
v4l2bufferpool: Fix race condition between qbuf and pool streamoff

There is a chance that pool->buffers[index] sets BUFFER_STATE_QUEUED, but
it has not been queued yet which makes pool->buffers[index] still NULL.
At this time, if pool_streamff release all buffers with BUFFER_STATE_QUEUED
state regardless of whether the buffer is NULL or not, it will cause segfault.

To fix this, also check buffer when streamoff release buffer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1842>
subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c