diff options
author | Christian Gromm <christian.gromm@microchip.com> | 2018-05-08 11:45:10 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-08 13:41:51 +0200 |
commit | 993c1637a08f436eacc7b3f4eacbda8dac0b304b (patch) | |
tree | 51dbb92b98b9d103e4fda89c5351625dd20c8a92 /drivers/staging/most/cdev | |
parent | 021fa2dbc49b7759945735250b56eba40e5166ce (diff) | |
download | linux-993c1637a08f436eacc7b3f4eacbda8dac0b304b.tar.bz2 |
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>
Diffstat (limited to 'drivers/staging/most/cdev')
-rw-r--r-- | drivers/staging/most/cdev/cdev.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c index 8e7652545402..4569838f27a0 100644 --- a/drivers/staging/most/cdev/cdev.c +++ b/drivers/staging/most/cdev/cdev.c @@ -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; } |