[media] v4l: vb2: Fix race condition in _vb2_fop_release
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sat, 1 Nov 2014 13:32:28 +0000 (10:32 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 4 Dec 2014 14:41:51 +0000 (12:41 -0200)
commit69c0e9c547817fef14871bc5c4645fad683f242e
tree1111885af6e5602910bdc1e144cd424948869cb8
parentf6cee18858b3c0adaa30cbe45a1766c8ef053c5d
[media] v4l: vb2: Fix race condition in _vb2_fop_release

The function releases the queue if the file being released is the queue
owner. The check reads the queue->owner field without taking the queue
lock, creating a race condition with functions that set the queue owner,
such as vb2_ioctl_reqbufs() for instance.

Fix this by moving the queue->owner check within the mutex protected
section.

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