LinuxTV Patchwork [RFC,1/8] cec: fix epoll() by calling poll_wait first

login
register
mail settings
Submitter Hans Verkuil
Date Feb. 7, 2019, 11:49 a.m.
Message ID <20190207114948.37750-2-hverkuil-cisco@xs4all.nl>
Download mbox | patch
Permalink /patch/54367/
State Accepted
Delegated to: Hans Verkuil
Headers show

Comments

Hans Verkuil - Feb. 7, 2019, 11:49 a.m.
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>

The epoll function expects that whenever the poll file op is
called, the poll_wait function is also called. That didn't
always happen in cec_poll(). Fix this, otherwise epoll()
would timeout when it shouldn't.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/cec/cec-api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Sean Young - Feb. 8, 2019, 8:53 p.m.
On Thu, Feb 07, 2019 at 12:49:41PM +0100, hverkuil-cisco@xs4all.nl wrote:
> From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> 
> The epoll function expects that whenever the poll file op is
> called, the poll_wait function is also called. That didn't
> always happen in cec_poll(). Fix this, otherwise epoll()
> would timeout when it shouldn't.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>  drivers/media/cec/cec-api.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c
> index 391b6fd483e1..156a0d76ab2a 100644
> --- a/drivers/media/cec/cec-api.c
> +++ b/drivers/media/cec/cec-api.c
> @@ -38,6 +38,7 @@ static __poll_t cec_poll(struct file *filp,
>  	struct cec_adapter *adap = fh->adap;
>  	__poll_t res = 0;
>  
> +	poll_wait(filp, &fh->wait, poll);
>  	if (!cec_is_registered(adap))
>  		return EPOLLERR | EPOLLHUP;
>  	mutex_lock(&adap->lock);
> @@ -48,7 +49,6 @@ static __poll_t cec_poll(struct file *filp,
>  		res |= EPOLLIN | EPOLLRDNORM;
>  	if (fh->total_queued_events)
>  		res |= EPOLLPRI;
> -	poll_wait(filp, &fh->wait, poll);
>  	mutex_unlock(&adap->lock);
>  	return res;
>  }
> -- 
> 2.20.1

Reviewed-by: Sean Young <sean@mess.org>


Sean

Patch

diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c
index 391b6fd483e1..156a0d76ab2a 100644
--- a/drivers/media/cec/cec-api.c
+++ b/drivers/media/cec/cec-api.c
@@ -38,6 +38,7 @@  static __poll_t cec_poll(struct file *filp,
 	struct cec_adapter *adap = fh->adap;
 	__poll_t res = 0;
 
+	poll_wait(filp, &fh->wait, poll);
 	if (!cec_is_registered(adap))
 		return EPOLLERR | EPOLLHUP;
 	mutex_lock(&adap->lock);
@@ -48,7 +49,6 @@  static __poll_t cec_poll(struct file *filp,
 		res |= EPOLLIN | EPOLLRDNORM;
 	if (fh->total_queued_events)
 		res |= EPOLLPRI;
-	poll_wait(filp, &fh->wait, poll);
 	mutex_unlock(&adap->lock);
 	return res;
 }

Privacy Policy