V4L/DVB (7556): em28xx: fix locking on vidioc_s_fmt_cap
authorAidan Thornton <makosoft@googlemail.com>
Sun, 13 Apr 2008 18:02:24 +0000 (15:02 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Thu, 24 Apr 2008 17:08:48 +0000 (14:08 -0300)
Currently, vidioc_s_fmt_cap is allowed even if streaming is running on some
other fh. This is likely to cause issues.

Block use of vidioc_s_fmt_cap if someone else has claimed access to the device.

Signed-off-by: Aidan Thornton <makosoft@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/em28xx/em28xx-video.c

index d6ada6226b54b8dd3cd913d489ab8e97dc30da3f..d3485f500c5e1785616c2302f4bf700c0b5dadbd 100644 (file)
@@ -947,6 +947,12 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv,
                goto out;
        }
 
+       if (dev->stream_on && !fh->stream_on) {
+               em28xx_errdev("%s device in use by another fh\n", __func__);
+               rc = -EBUSY;
+               goto out;
+       }
+
        /* set new image size */
        dev->width = f->fmt.pix.width;
        dev->height = f->fmt.pix.height;