All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for v5.3] videobuf-core.c: poll_wait needs a non-NULL buf pointer
@ 2019-09-04  9:04 Hans Verkuil
  2019-09-05  8:24 ` Hans Verkuil
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2019-09-04  9:04 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Dan Carpenter

poll_wait uses &buf->done, but buf is NULL. Move the poll_wait to later
in the function once buf is correctly set and only call it if it is
non-NULL.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: bb436cbeb918 ("media: videobuf: fix epoll() by calling poll_wait first")
Cc: <stable@vger.kernel.org>      # for v5.1 and up
---
diff --git a/drivers/media/v4l2-core/videobuf-core.c b/drivers/media/v4l2-core/videobuf-core.c
index 7ef3e4d22bf6..939fc11cf080 100644
--- a/drivers/media/v4l2-core/videobuf-core.c
+++ b/drivers/media/v4l2-core/videobuf-core.c
@@ -1123,7 +1123,6 @@ __poll_t videobuf_poll_stream(struct file *file,
 	struct videobuf_buffer *buf = NULL;
 	__poll_t rc = 0;

-	poll_wait(file, &buf->done, wait);
 	videobuf_queue_lock(q);
 	if (q->streaming) {
 		if (!list_empty(&q->stream))
@@ -1143,7 +1142,9 @@ __poll_t videobuf_poll_stream(struct file *file,
 		}
 		buf = q->read_buf;
 	}
-	if (!buf)
+	if (buf)
+		poll_wait(file, &buf->done, wait);
+	else
 		rc = EPOLLERR;

 	if (0 == rc) {

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH for v5.3] videobuf-core.c: poll_wait needs a non-NULL buf pointer
  2019-09-04  9:04 [PATCH for v5.3] videobuf-core.c: poll_wait needs a non-NULL buf pointer Hans Verkuil
@ 2019-09-05  8:24 ` Hans Verkuil
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Verkuil @ 2019-09-05  8:24 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Dan Carpenter

On 9/4/19 11:04 AM, Hans Verkuil wrote:
> poll_wait uses &buf->done, but buf is NULL. Move the poll_wait to later
> in the function once buf is correctly set and only call it if it is
> non-NULL.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Fixes: bb436cbeb918 ("media: videobuf: fix epoll() by calling poll_wait first")
> Cc: <stable@vger.kernel.org>      # for v5.1 and up

Tested with the cx231xx driver:

Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

> ---
> diff --git a/drivers/media/v4l2-core/videobuf-core.c b/drivers/media/v4l2-core/videobuf-core.c
> index 7ef3e4d22bf6..939fc11cf080 100644
> --- a/drivers/media/v4l2-core/videobuf-core.c
> +++ b/drivers/media/v4l2-core/videobuf-core.c
> @@ -1123,7 +1123,6 @@ __poll_t videobuf_poll_stream(struct file *file,
>  	struct videobuf_buffer *buf = NULL;
>  	__poll_t rc = 0;
> 
> -	poll_wait(file, &buf->done, wait);
>  	videobuf_queue_lock(q);
>  	if (q->streaming) {
>  		if (!list_empty(&q->stream))
> @@ -1143,7 +1142,9 @@ __poll_t videobuf_poll_stream(struct file *file,
>  		}
>  		buf = q->read_buf;
>  	}
> -	if (!buf)
> +	if (buf)
> +		poll_wait(file, &buf->done, wait);
> +	else
>  		rc = EPOLLERR;
> 
>  	if (0 == rc) {
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-05  8:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04  9:04 [PATCH for v5.3] videobuf-core.c: poll_wait needs a non-NULL buf pointer Hans Verkuil
2019-09-05  8:24 ` Hans Verkuil

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.