[media] bttv: fix mutex use before init (BZ#24602)
authorMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 15 Dec 2010 21:45:42 +0000 (18:45 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 17 Dec 2010 20:39:43 +0000 (18:39 -0200)
commit587f0d5d6d44e3529028bf197d424f866fb2411d
tree78baa254ab816cfce7cc37e6b4f294e94ab2f689
parenta757ee2216211278680dd8ac869aabe7b4a9970d
[media] bttv: fix mutex use before init (BZ#24602)

Fix a regression where bttv driver causes oopses when loading, since it
were using some non-initialized mutexes. While it would be possible to
fix the issue, there are some other lock troubles, like to the presence of
lock code at free_btres_lock().

It is possible to fix, but the better is to just use the core-assisted
locking schema. This way, V4L2 core will serialize access to all
ioctl's/open/close/mmap/read/poll operations, avoiding to have two
processes accessing the hardware at the same time. Also, as there's just
one lock, instead of 3, there's no risk of dead locks.

The net result is a cleaner code, with just one lock.

Reported-by: Dan Carpenter <error27@gmail.com>
Reported-by: Brandon Philips<brandon@ifup.org>
Reported-by: Chris Clayton <chris2553@googlemail.com>
Reported-by: Torsten Kaiser <just.for.lkml@googlemail.com>
Tested-by: Chris Clayton <chris2553@googlemail.com>
Tested-by: Torsten Kaiser <just.for.lkml@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/bt8xx/bttv-driver.c