diff mbox

[1/1,net-next] net/atm/signaling.c: replace current->state by __set_current_state()

Message ID 1424712667-11849-1-git-send-email-fabf@skynet.be
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Fabian Frederick Feb. 23, 2015, 5:31 p.m. UTC
Use helper functions to access current->state.
Direct assignments are prone to races and therefore buggy.

Thanks to Peter Zijlstra for the exact definition of the problem.

Suggested-By: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 net/atm/signaling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

chas williams - CONTRACTOR Feb. 23, 2015, 5:50 p.m. UTC | #1
Instead of fixing code that never gets compiled/test, you could probably
just remove the #if WAIT_FOR_DAEMON code which would get rid of this
raw assignment.

See the #undef around line 268.

On Mon, 23 Feb 2015 18:31:07 +0100
Fabian Frederick <fabf@skynet.be> wrote:

> Use helper functions to access current->state.
> Direct assignments are prone to races and therefore buggy.
> 
> Thanks to Peter Zijlstra for the exact definition of the problem.
> 
> Suggested-By: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
>  net/atm/signaling.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/atm/signaling.c b/net/atm/signaling.c
> index 523bce7..0140832 100644
> --- a/net/atm/signaling.c
> +++ b/net/atm/signaling.c
> @@ -40,7 +40,7 @@ static void sigd_put_skb(struct sk_buff *skb)
>  		pr_debug("atmsvc: waiting for signaling daemon...\n");
>  		schedule();
>  	}
> -	current->state = TASK_RUNNING;
> +	__set_current_state(TASK_RUNNING);
>  	remove_wait_queue(&sigd_sleep, &wait);
>  #else
>  	if (!sigd) {

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Feb. 23, 2015, 10:20 p.m. UTC | #2
From: chas williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Date: Mon, 23 Feb 2015 12:50:25 -0500

> Instead of fixing code that never gets compiled/test, you could probably
> just remove the #if WAIT_FOR_DAEMON code which would get rid of this
> raw assignment.
> 
> See the #undef around line 268.

I completely agree.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/atm/signaling.c b/net/atm/signaling.c
index 523bce7..0140832 100644
--- a/net/atm/signaling.c
+++ b/net/atm/signaling.c
@@ -40,7 +40,7 @@  static void sigd_put_skb(struct sk_buff *skb)
 		pr_debug("atmsvc: waiting for signaling daemon...\n");
 		schedule();
 	}
-	current->state = TASK_RUNNING;
+	__set_current_state(TASK_RUNNING);
 	remove_wait_queue(&sigd_sleep, &wait);
 #else
 	if (!sigd) {