summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimur Celik <mail@timurcelik.de>2019-02-23 14:53:13 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-03-14 00:04:54 +0300
commit689b5a2970b8e09621acb693dcaa762c0330cd1e (patch)
tree208b7e29042ce071e549f5fd3794761a4a3a82a2
parent3b448977879f7b25f5171de3b58755658f92f1ae (diff)
downloadlinux-689b5a2970b8e09621acb693dcaa762c0330cd1e.tar.xz
tun: fix blocking read
[ Upstream commit 71828b2240692cec0e68b8d867bc00e1745e7fae ] 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-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 7a0d5e928bec..7e082df135dc 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1471,9 +1471,9 @@ static struct sk_buff *tun_ring_recv(struct tun_file *tfile, int noblock,
}
add_wait_queue(&tfile->wq.wait, &wait);
- current->state = TASK_INTERRUPTIBLE;
while (1) {
+ set_current_state(TASK_INTERRUPTIBLE);
skb = skb_array_consume(&tfile->tx_array);
if (skb)
break;
@@ -1489,7 +1489,7 @@ static struct sk_buff *tun_ring_recv(struct tun_file *tfile, int noblock,
schedule();
}
- current->state = TASK_RUNNING;
+ set_current_state(TASK_RUNNING);
remove_wait_queue(&tfile->wq.wait, &wait);
out: