]> err.no Git - linux-2.6/commitdiff
Fix a deadlock in the bttv driver
authorArjan van de Ven <arjan@linux.intel.com>
Tue, 20 May 2008 16:53:52 +0000 (09:53 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 20 May 2008 17:12:26 +0000 (10:12 -0700)
vidiocgmbuf() does this:
        mutex_lock(&fh->cap.vb_lock);
        retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
                                     V4L2_MEMORY_MMAP);

and videobuf_mmap_setup() then just does
        mutex_lock(&q->vb_lock);
        ret = __videobuf_mmap_setup(q, bcount, bsize, memory);
        mutex_unlock(&q->vb_lock);

which is an obvious double-take deadlock.

This patch fixes this by having vidiocgmbuf() just call the
__videobuf_mmap_setup function instead.

Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Reported-by: Koos Vriezen <koos.vriezen@gmail.com>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/media/video/bt8xx/bttv-driver.c
drivers/media/video/videobuf-core.c
include/media/videobuf-core.h

index 2ca3e9cfb2bbbaf0887e70e23624268002e328f5..0165aac533bf1d98eb7d7c9f2a0c4cf71f61d11e 100644 (file)
@@ -2613,7 +2613,7 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
        struct bttv_fh *fh = priv;
 
        mutex_lock(&fh->cap.vb_lock);
-       retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
+       retval = __videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
                                     V4L2_MEMORY_MMAP);
        if (retval < 0) {
                mutex_unlock(&fh->cap.vb_lock);
index 982f4463896c68ed74361dacc3c57918a9fb1212..0a88c44ace00b20199e8606cef813234d39e5c74 100644 (file)
@@ -331,7 +331,7 @@ int videobuf_mmap_free(struct videobuf_queue *q)
 }
 
 /* Locking: Caller holds q->vb_lock */
-static int __videobuf_mmap_setup(struct videobuf_queue *q,
+int __videobuf_mmap_setup(struct videobuf_queue *q,
                        unsigned int bcount, unsigned int bsize,
                        enum v4l2_memory memory)
 {
@@ -1129,6 +1129,7 @@ EXPORT_SYMBOL_GPL(videobuf_read_stream);
 EXPORT_SYMBOL_GPL(videobuf_read_one);
 EXPORT_SYMBOL_GPL(videobuf_poll_stream);
 
+EXPORT_SYMBOL_GPL(__videobuf_mmap_setup);
 EXPORT_SYMBOL_GPL(videobuf_mmap_setup);
 EXPORT_SYMBOL_GPL(videobuf_mmap_free);
 EXPORT_SYMBOL_GPL(videobuf_mmap_mapper);
index 5b39a22533fea113254186a9157c9b24f0be5bbf..874f1340d0493d9f8f1e66a5186ae984e9e93a51 100644 (file)
@@ -237,6 +237,9 @@ unsigned int videobuf_poll_stream(struct file *file,
 int videobuf_mmap_setup(struct videobuf_queue *q,
                        unsigned int bcount, unsigned int bsize,
                        enum v4l2_memory memory);
+int __videobuf_mmap_setup(struct videobuf_queue *q,
+                       unsigned int bcount, unsigned int bsize,
+                       enum v4l2_memory memory);
 int videobuf_mmap_free(struct videobuf_queue *q);
 int videobuf_mmap_mapper(struct videobuf_queue *q,
                         struct vm_area_struct *vma);