diff mbox series

tun: fix blocking read

Message ID 20190223115313.15064-1-mail@timurcelik.de
State Accepted
Delegated to: David Miller
Headers show
Series tun: fix blocking read | expand

Commit Message

Timur Celik Feb. 23, 2019, 11:53 a.m. UTC
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>
---
 drivers/net/tun.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Miller Feb. 25, 2019, 6:12 a.m. UTC | #1
From: Timur Celik <mail@timurcelik.de>
Date: Sat, 23 Feb 2019 12:53:13 +0100

> 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>

Applied and queued up for -stable, thanks.
Eric Dumazet Feb. 25, 2019, 3:53 p.m. UTC | #2
On 02/24/2019 10:12 PM, David Miller wrote:
> From: Timur Celik <mail@timurcelik.de>
> Date: Sat, 23 Feb 2019 12:53:13 +0100
> 
>> 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>
> 
> Applied and queued up for -stable, thanks.
> 

First part of the patch was matching the changelog, however
the second change was not really needed, or should have used 

__set_current_state(TASK_RUNNING);
David Miller Feb. 25, 2019, 6:25 p.m. UTC | #3
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 25 Feb 2019 07:53:08 -0800

> 
> 
> On 02/24/2019 10:12 PM, David Miller wrote:
>> From: Timur Celik <mail@timurcelik.de>
>> Date: Sat, 23 Feb 2019 12:53:13 +0100
>> 
>>> 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>
>> 
>> Applied and queued up for -stable, thanks.
>> 
> 
> First part of the patch was matching the changelog, however
> the second change was not really needed, or should have used 
> 
> __set_current_state(TASK_RUNNING);

Timur, please followup.
Timur Celik Feb. 25, 2019, 8:12 p.m. UTC | #4
On Mon, Feb 25, 2019 at 10:25:48AM -0800, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Mon, 25 Feb 2019 07:53:08 -0800
> 
>> 
>> 
>> On 02/24/2019 10:12 PM, David Miller wrote:
>>> From: Timur Celik <mail@timurcelik.de>
>>> Date: Sat, 23 Feb 2019 12:53:13 +0100
>>> 
>>>> 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>
>>> 
>>> Applied and queued up for -stable, thanks.
>>> 
>> 
>> First part of the patch was matching the changelog, however
>> the second change was not really needed, or should have used 
>> 
>> __set_current_state(TASK_RUNNING);
> 
> Timur, please followup.

Thanks for taking a look at this. Eric is right of course.
diff mbox series

Patch

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: