staging: most: cdev: fix race condition

This patch fixes a race condition between the functions disconnect and poll.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Christian Gromm 2018-05-08 11:45:10 +02:00 committed by Greg Kroah-Hartman
parent 021fa2dbc4
commit 993c1637a0
1 changed files with 4 additions and 2 deletions

View File

@ -292,13 +292,15 @@ static __poll_t comp_poll(struct file *filp, poll_table *wait)
poll_wait(filp, &c->wq, wait);
mutex_lock(&c->io_mutex);
if (c->cfg->direction == MOST_CH_RX) {
if (!kfifo_is_empty(&c->fifo))
if (!c->dev || !kfifo_is_empty(&c->fifo))
mask |= EPOLLIN | EPOLLRDNORM;
} else {
if (!kfifo_is_empty(&c->fifo) || ch_has_mbo(c))
if (!c->dev || !kfifo_is_empty(&c->fifo) || ch_has_mbo(c))
mask |= EPOLLOUT | EPOLLWRNORM;
}
mutex_unlock(&c->io_mutex);
return mask;
}