[media] vb2: fix wrong owner check
authorHans Verkuil <hans.verkuil@cisco.com>
Fri, 7 Sep 2012 15:50:02 +0000 (12:50 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 26 Sep 2012 18:44:11 +0000 (15:44 -0300)
Check against q->fileio to see if the queue owner should be set or not.
The former check against the return value of read or write is wrong, since
read/write can return an error, even if the queue is in streaming mode.
For example, EAGAIN when in non-blocking mode.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/v4l2-core/videobuf2-core.c

index 4da3df61901fbf549f7192af3c93518e5acc5e83..59ed5223393bdccfcfda7a98f6495522d33bbe1a 100644 (file)
@@ -2278,7 +2278,7 @@ ssize_t vb2_fop_write(struct file *file, char __user *buf,
                goto exit;
        err = vb2_write(vdev->queue, buf, count, ppos,
                       file->f_flags & O_NONBLOCK);
-       if (err >= 0)
+       if (vdev->queue->fileio)
                vdev->queue->owner = file->private_data;
 exit:
        if (lock)
@@ -2300,7 +2300,7 @@ ssize_t vb2_fop_read(struct file *file, char __user *buf,
                goto exit;
        err = vb2_read(vdev->queue, buf, count, ppos,
                       file->f_flags & O_NONBLOCK);
-       if (err >= 0)
+       if (vdev->queue->fileio)
                vdev->queue->owner = file->private_data;
 exit:
        if (lock)