All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: linux-media@vger.kernel.org
Cc: Andy Walls <awalls@md.metrocast.net>,
	Hans Verkuil <hans.verkuil@cisco.com>
Subject: [PATCH 1/8] vb2: set owner before calling vb2_read
Date: Wed,  1 Feb 2023 17:11:46 +0100	[thread overview]
Message-ID: <20230201161153.883376-2-hverkuil-cisco@xs4all.nl> (raw)
In-Reply-To: <20230201161153.883376-1-hverkuil-cisco@xs4all.nl>

From: Hans Verkuil <hans.verkuil@cisco.com>

Before vb2_read is called, the owner must be set since vb2_read will actually
start streaming. If vb2_read returns an error and q->fileio is NULL, then
it failed to start streaming and the owner is set back to NULL.

When the vb2 start_streaming callback is called, it expects the owner
pointer to be set, and that wasn't the case in this particular situation.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/common/videobuf2/videobuf2-v4l2.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 1f5d235a8441..c7a54d82a55e 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -1171,10 +1171,11 @@ ssize_t vb2_fop_read(struct file *file, char __user *buf,
 		return -ERESTARTSYS;
 	if (vb2_queue_is_busy(vdev->queue, file))
 		goto exit;
+	vdev->queue->owner = file->private_data;
 	err = vb2_read(vdev->queue, buf, count, ppos,
 		       file->f_flags & O_NONBLOCK);
-	if (vdev->queue->fileio)
-		vdev->queue->owner = file->private_data;
+	if (!vdev->queue->fileio)
+		vdev->queue->owner = NULL;
 exit:
 	if (lock)
 		mutex_unlock(lock);
-- 
2.39.0


  reply	other threads:[~2023-02-01 16:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 16:11 [PATCH 0/8] cx18: convert to vb2 Hans Verkuil
2023-02-01 16:11 ` Hans Verkuil [this message]
2023-02-01 16:11 ` [PATCH 2/8] v4l2-dev.c: check for V4L2_CAP_STREAMING to enable streaming ioctls Hans Verkuil
2023-02-01 16:11 ` [PATCH 3/8] cx18: convert to vb2 Hans Verkuil
2023-02-01 16:11 ` [PATCH 4/8] cx18: fix incorrect input counting Hans Verkuil
2023-02-01 16:11 ` [PATCH 5/8] cx18: properly report pixelformats Hans Verkuil
2023-02-01 16:11 ` [PATCH 6/8] cx18: missing CAP_AUDIO for vbi stream Hans Verkuil
2023-02-01 16:11 ` [PATCH 7/8] cx18: reorder fmt_vid_cap functions in cx18-ioctl.c Hans Verkuil
2023-02-01 16:11 ` [PATCH 8/8] cx18: fix format compliance issues Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230201161153.883376-2-hverkuil-cisco@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=awalls@md.metrocast.net \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.