From: Hans Verkuil Date: Fri, 13 Dec 2013 16:13:40 +0000 (-0300) Subject: [media] vb2: fix race condition between REQBUFS and QBUF/PREPARE_BUF X-Git-Tag: v3.14-rc1~20^2~114 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63faabfd89f4db9862ae2a663193e511419c67eb;p=pandora-kernel.git [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 Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- Reading git-diff-tree failed