[PATCH 0/2] vb2: check for events before checking for buffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patches fix a race condition in the poll functions of v4l2 devices.

Whenever a driver returns a buffer with the V4L2_BUF_FLAG_LAST flag set, it
must also return a V4L2_EVENT_EOS. Checking for events before checking for
buffers creates a race condition where drivers can return the buffer and event
between the checks and thus only signal the buffer without the event.
Reordering the checks avoids the race condition.

I discovered this issue in the allegro-dvt driver [0].

Michael

[0] https://lore.kernel.org/linux-media/20190527154557.62278063@xxxxxxxxxxxxxxxxxxxxxxxxx/

Michael Tretter (2):
  media: vb2: reorder checks in vb2_poll()
  media: v4l2-mem2mem: reorder checks in v4l2_m2m_poll()

 .../media/common/videobuf2/videobuf2-v4l2.c   |  8 ++--
 drivers/media/v4l2-core/v4l2-mem2mem.c        | 47 +++++++++++--------
 2 files changed, 32 insertions(+), 23 deletions(-)

-- 
2.20.1




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux