summaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core/videobuf-dma-sg.c
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2013-05-09 15:03:33 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-05-21 08:56:56 -0300
commita242f426108c284049a69710f871cc9f11b13e61 (patch)
tree0cddab2680085f478cf5c5c5b168143de90e8b30 /drivers/media/v4l2-core/videobuf-dma-sg.c
parent0735647c29bca5f33f38fcf457b3b0e9e5912f51 (diff)
downloadblackbird-op-linux-a242f426108c284049a69710f871cc9f11b13e61.tar.gz
blackbird-op-linux-a242f426108c284049a69710f871cc9f11b13e61.zip
[media] videobuf_vm_{open,close} race fixes
just use videobuf_queue_lock(map->q) to protect map->count; vm_area_operations ->open() and ->close() are called just under vma->vm_mm->mmap_sem, which doesn't help the drivers at all, since clonal VMAs are normally in different address spaces... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/v4l2-core/videobuf-dma-sg.c')
-rw-r--r--drivers/media/v4l2-core/videobuf-dma-sg.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c
index 828e7c10bd70..9db674ccdc68 100644
--- a/drivers/media/v4l2-core/videobuf-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf-dma-sg.c
@@ -338,11 +338,14 @@ EXPORT_SYMBOL_GPL(videobuf_dma_free);
static void videobuf_vm_open(struct vm_area_struct *vma)
{
struct videobuf_mapping *map = vma->vm_private_data;
+ struct videobuf_queue *q = map->q;
dprintk(2, "vm_open %p [count=%d,vma=%08lx-%08lx]\n", map,
map->count, vma->vm_start, vma->vm_end);
+ videobuf_queue_lock(q);
map->count++;
+ videobuf_queue_unlock(q);
}
static void videobuf_vm_close(struct vm_area_struct *vma)
@@ -355,10 +358,9 @@ static void videobuf_vm_close(struct vm_area_struct *vma)
dprintk(2, "vm_close %p [count=%d,vma=%08lx-%08lx]\n", map,
map->count, vma->vm_start, vma->vm_end);
- map->count--;
- if (0 == map->count) {
+ videobuf_queue_lock(q);
+ if (!--map->count) {
dprintk(1, "munmap %p q=%p\n", map, q);
- videobuf_queue_lock(q);
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
if (NULL == q->bufs[i])
continue;
@@ -374,9 +376,9 @@ static void videobuf_vm_close(struct vm_area_struct *vma)
q->bufs[i]->baddr = 0;
q->ops->buf_release(q, q->bufs[i]);
}
- videobuf_queue_unlock(q);
kfree(map);
}
+ videobuf_queue_unlock(q);
return;
}
OpenPOWER on IntegriCloud