media: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set
authorMing Qian <ming.qian@nxp.com>
Wed, 15 Jun 2022 03:19:20 +0000 (04:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:23:23 +0000 (14:23 +0200)
commitdb01d107c21f82dfd9d76c95e3c17e7147d34297
treebc06f1281ec78fb8d1a192a7b55ab6fabf58b7c3
parent7ca91b2d870fecb8c1696ae9fb5c96f6efc2cbda
media: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set

[ Upstream commit d4de27a9b1eadd33a2e40de87a646d1bf5fef756 ]

If the last buffer was dequeued from the capture queue,
signal userspace. DQBUF(CAPTURE) will return -EPIPE.

But if output queue is empty and capture queue is empty,
v4l2_m2m_poll_for_data will return EPOLLERR,
This is very easy to happen in drain.

When last_buffer_dequeued is set, we shouldn't return EPOLLERR,
but return EPOLLIN | EPOLLRDNORM.

Fixes: 1698a7f151126 ("media: v4l2-mem2mem: simplify poll logic")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/v4l2-core/v4l2-mem2mem.c