]> rtime.felk.cvut.cz Git - can-eth-gw-linux.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)
commitb037c0fde22b1d3cd0b3c3717d28e54619fc1592
tree92d4c05c8e3f777c288546d5592cdf8ce4b70a89
parentf0b7c7fc6f15e823cb4a5d225d9ef28b884ab6ec
[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