The patch number 8108 was added via Mauro Carvalho Chehab <[EMAIL PROTECTED]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        [EMAIL PROTECTED]

------

From: Arjan van de Ven  <[EMAIL PROTECTED]>
 Fix open/close race in saa7134


The saa7134 driver uses a (non-atomic) variable in an attempt to
only allow one opener of the device (how it deals with sending
the fd over unix sockets I don't know).

Unfortunately, the release function first decrements this variable,
and THEN goes on to disable more of the device. This allows for
a race where another opener of the device comes in after the decrement of
the variable, configures the hardware just to then see the hardware
be disabled by the rest of the release function.

This patch makes the release function use the same lock as the open
function to protect the hardware as well as the variable (which now
at least has some locking to protect it).

Signed-off-by: Arjan van de Ven <[EMAIL PROTECTED]>
Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>


---

 linux/drivers/media/video/saa7134/saa7134-empress.c |    4 ++++
 1 file changed, 4 insertions(+)

diff -r 595fe1ec7511 -r 9abb7597d435 
linux/drivers/media/video/saa7134/saa7134-empress.c
--- a/linux/drivers/media/video/saa7134/saa7134-empress.c       Sun Jun 22 
14:11:13 2008 +0200
+++ b/linux/drivers/media/video/saa7134/saa7134-empress.c       Sun Jun 22 
17:03:02 2008 +0000
@@ -119,6 +119,8 @@ static int ts_release(struct inode *inod
 {
        struct saa7134_dev *dev = file->private_data;
 
+       mutex_lock(&dev->empress_tsq.vb_lock);
+
        videobuf_stop(&dev->empress_tsq);
        videobuf_mmap_free(&dev->empress_tsq);
 
@@ -130,6 +132,8 @@ static int ts_release(struct inode *inod
                saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6));
 
        dev->empress_users--;
+
+       mutex_unlock(&dev->empress_tsq.vb_lock);
 
        return 0;
 }


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/9abb7597d435bb5e36079251353d1a008ed524f7

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to