]> git.baikalelectronics.ru Git - kernel.git/commit
[media] media: vb2: fix potential deadlock in mmap vs. get_userptr handling
authorMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 17 Nov 2011 08:32:17 +0000 (05:32 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 30 Dec 2011 18:06:49 +0000 (16:06 -0200)
commitacb8aa712715902d5cfd0a874bb79538a9716f88
tree92d4c05c8e3f777c288546d5592cdf8ce4b70a89
parent9464b8acf032495ccb49efcfde4e814b09a12d24
[media] media: vb2: fix potential deadlock in mmap vs. get_userptr handling

To get direct access to userspace memory pages vb2 allocator needs to
gather read access on mmap semaphore in the current process.
The same semaphore is taken before calling mmap operation, while
both mmap and qbuf are called by the driver or v4l2 core with
driver's lock held. To avoid a AB-BA deadlock (mmap_sem then
driver's lock in mmap and driver's lock then mmap_sem in qbuf)
the videobuf2 core release driver's lock, takes mmap_sem and then
takes again driver's lock. get_userptr methods are now called with
all needed locks already taken to avoid further lock magic inside
memory allocator's code.

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/videobuf2-core.c
drivers/media/video/videobuf2-dma-sg.c
drivers/media/video/videobuf2-memops.c