Skip to content

Commit

Permalink
irda: replace current->state by set_current_state()
Browse files Browse the repository at this point in the history
Use helper functions to access current->state.
Direct assignments are prone to races and therefore buggy.

current->state = TASK_RUNNING can be replaced by __set_current_state()

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Fabian Frederick authored and David S. Miller committed Feb 23, 2015
1 parent 30ff547 commit a948f8c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion net/irda/ircomm/ircomm_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
break;
}
spin_unlock_irqrestore(&self->spinlock, flags);
current->state = TASK_RUNNING;
__set_current_state(TASK_RUNNING);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions net/irda/irnet/irnet_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ irnet_ctrl_read(irnet_socket * ap,

/* Put ourselves on the wait queue to be woken up */
add_wait_queue(&irnet_events.rwait, &wait);
current->state = TASK_INTERRUPTIBLE;
set_current_state(TASK_INTERRUPTIBLE);
for(;;)
{
/* If there is unread events */
Expand All @@ -321,7 +321,7 @@ irnet_ctrl_read(irnet_socket * ap,
/* Yield and wait to be woken up */
schedule();
}
current->state = TASK_RUNNING;
__set_current_state(TASK_RUNNING);
remove_wait_queue(&irnet_events.rwait, &wait);

/* Did we got it ? */
Expand Down

0 comments on commit a948f8c

Please sign in to comment.