]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: cec: fix epoll() by calling poll_wait first
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Thu, 7 Feb 2019 11:49:41 +0000 (06:49 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 18 Feb 2019 19:44:45 +0000 (14:44 -0500)
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>
Reviewed-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/cec/cec-api.c

index 391b6fd483e14b0237ca45aee2e519816c61ea25..156a0d76ab2a1efe8d791c57dfcb76cfe0beb9ed 100644 (file)
@@ -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;
 }