From: Hans Verkuil <hverkuil-cisco@xxxxxxxxx> This supersedes my previous patch: https://www.mail-archive.com/linux-media@xxxxxxxxxxxxxxx/msg144099.html Rather than marking a timestamp of 0 as 'special', I add a bitfield to keep track of the validity of the timestamp. The last patch also adds extra checks to verify that the found buffer matches what is expected w.r.t. the number of planes and the size of the planes. I still think vb2_find_timestamp should increase some refcount for the buffer since it is possible that the application requeues the found buffer with a different dmabuf fd, thus potentially freeing the buffer memory while it is still being processed. But to be honest, I'm not sure how that should be done. Regards, Hans Hans Verkuil (3): vb2: replace bool by bitfield in vb2_buffer vb2: keep track of timestamp status vb2: add 'match' arg to vb2_find_buffer() drivers/media/common/videobuf2/videobuf2-core.c | 15 +++++++++------ drivers/media/common/videobuf2/videobuf2-v4l2.c | 16 +++++++++++++--- drivers/media/v4l2-core/v4l2-mem2mem.c | 1 + .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 8 ++++---- include/media/videobuf2-core.h | 7 +++++-- include/media/videobuf2-v4l2.h | 3 ++- 6 files changed, 34 insertions(+), 16 deletions(-) -- 2.20.1