]> git.karo-electronics.de Git - linux-beck.git/commit
[media] vb2: fix race condition between REQBUFS and QBUF/PREPARE_BUF
authorHans Verkuil <hans.verkuil@cisco.com>
Fri, 13 Dec 2013 16:13:40 +0000 (13:13 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 7 Jan 2014 09:08:47 +0000 (07:08 -0200)
commit63faabfd89f4db9862ae2a663193e511419c67eb
treedaf06328aa1e9e234cbb481e9a5f5c12a1818ac1
parent4138111a27859dcc56a5592c804dd16bb12a23d1
[media] vb2: fix race condition between REQBUFS and QBUF/PREPARE_BUF

When preparing a buffer the queue lock is released for a short while
if the memory mode is USERPTR (see __buf_prepare for the details), which
would allow a race with a REQBUFS which can free the buffers. Removing the
buffers from underneath __buf_prepare is obviously a bad idea, so we
check if any of the buffers is in the state PREPARING, and if so we
just return -EAGAIN.

If this happens, then the application does something really strange. The
REQBUFS call can be retried safely, since this situation is transient.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/v4l2-core/videobuf2-core.c