V4L/DVB: gspca - main: Check the file doing stream on/off
authorJean-François Moine <moinejf@free.fr>
Fri, 9 Apr 2010 09:06:11 +0000 (06:06 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 19 May 2010 15:57:54 +0000 (12:57 -0300)
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/gspca/gspca.c

index 68a8431..4fb031c 100644 (file)
@@ -1590,6 +1590,12 @@ static int vidioc_streamon(struct file *file, void *priv,
        if (mutex_lock_interruptible(&gspca_dev->queue_lock))
                return -ERESTARTSYS;
 
+       /* check the capture file */
+       if (gspca_dev->capt_file != file) {
+               ret = -EBUSY;
+               goto out;
+       }
+
        if (gspca_dev->nframes == 0
            || !(gspca_dev->frame[0].v4l2_buf.flags & V4L2_BUF_FLAG_QUEUED)) {
                ret = -EINVAL;
@@ -1627,6 +1633,12 @@ static int vidioc_streamoff(struct file *file, void *priv,
        if (mutex_lock_interruptible(&gspca_dev->queue_lock))
                return -ERESTARTSYS;
 
+       /* check the capture file */
+       if (gspca_dev->capt_file != file) {
+               ret = -EBUSY;
+               goto out;
+       }
+
        /* stop streaming */
        if (mutex_lock_interruptible(&gspca_dev->usb_lock)) {
                ret = -ERESTARTSYS;