V4L/DVB (8022): saa7134: fix race between opening and closing the device
authorMarcin Slusarz <marcin.slusarz@gmail.com>
Tue, 10 Jun 2008 18:18:16 +0000 (15:18 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Thu, 26 Jun 2008 18:58:46 +0000 (15:58 -0300)
decrementing dev->empress_users should be done as last action of ts_release,
because it sleeps and write access to dev->empress_started is not protected
in any way
(additionally closing thread could mute audio after opening thread unmuted it)

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/saa7134/saa7134-empress.c

index 94b2585bdf5b095f6d5edc9be8852e4741cbe77f..1c8cd0ef4a6502718e21906d618f4b6ab7cf5dac 100644 (file)
@@ -112,7 +112,6 @@ static int ts_release(struct inode *inode, struct file *file)
 
        videobuf_stop(&dev->empress_tsq);
        videobuf_mmap_free(&dev->empress_tsq);
-       dev->empress_users--;
 
        /* stop the encoder */
        ts_reset_encoder(dev);
@@ -121,6 +120,8 @@ static int ts_release(struct inode *inode, struct file *file)
        saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
                saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6));
 
+       dev->empress_users--;
+
        return 0;
 }