summaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorTimur Celik <mail@timurcelik.de>2019-02-23 12:53:13 +0100
committerDavid S. Miller <davem@davemloft.net>2019-02-24 22:11:53 -0800
commit71828b2240692cec0e68b8d867bc00e1745e7fae (patch)
tree5a20187191aaf271f6d39b65407c62e0dbd9c389 /drivers/net/tun.c
parentcffde20164d2a1e7d647b63b4d8fac11bf48b500 (diff)
downloadblackbird-op-linux-71828b2240692cec0e68b8d867bc00e1745e7fae.tar.gz
blackbird-op-linux-71828b2240692cec0e68b8d867bc00e1745e7fae.zip
tun: fix blocking read
This patch moves setting of the current state into the loop. Otherwise the task may end up in a busy wait loop if none of the break conditions are met. Signed-off-by: Timur Celik <mail@timurcelik.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index fed298c0cb39..d291762b9e9d 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2167,9 +2167,9 @@ static void *tun_ring_recv(struct tun_file *tfile, int noblock, int *err)
}
add_wait_queue(&tfile->wq.wait, &wait);
- current->state = TASK_INTERRUPTIBLE;
while (1) {
+ set_current_state(TASK_INTERRUPTIBLE);
ptr = ptr_ring_consume(&tfile->tx_ring);
if (ptr)
break;
@@ -2185,7 +2185,7 @@ static void *tun_ring_recv(struct tun_file *tfile, int noblock, int *err)
schedule();
}
- current->state = TASK_RUNNING;
+ set_current_state(TASK_RUNNING);
remove_wait_queue(&tfile->wq.wait, &wait);
out:
OpenPOWER on IntegriCloud