diff options
author | Fabian Frederick <fabf@skynet.be> | 2015-02-20 13:12:56 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-22 15:24:10 -0500 |
commit | 2c45015a66a171de306e23991fec998667b49acf (patch) | |
tree | 016747c3d73ec9a3802ba19fad9724a52258d9cb | |
parent | 50462ce0052c67b5a06f19fb7c7f308813006879 (diff) |
wan: cosa: replace current->state by set_current_state()
Use helper functions to access current->state.
Direct assignments are prone to races and therefore buggy.
current->state = TASK_RUNNING is 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>
Acked-By: Jan "Yenya" Kasprzak <kas@fi.muni.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/wan/cosa.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index 83c39e2858bf..88d121d43c08 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c | |||
@@ -806,21 +806,21 @@ static ssize_t cosa_read(struct file *file, | |||
806 | spin_lock_irqsave(&cosa->lock, flags); | 806 | spin_lock_irqsave(&cosa->lock, flags); |
807 | add_wait_queue(&chan->rxwaitq, &wait); | 807 | add_wait_queue(&chan->rxwaitq, &wait); |
808 | while (!chan->rx_status) { | 808 | while (!chan->rx_status) { |
809 | current->state = TASK_INTERRUPTIBLE; | 809 | set_current_state(TASK_INTERRUPTIBLE); |
810 | spin_unlock_irqrestore(&cosa->lock, flags); | 810 | spin_unlock_irqrestore(&cosa->lock, flags); |
811 | schedule(); | 811 | schedule(); |
812 | spin_lock_irqsave(&cosa->lock, flags); | 812 | spin_lock_irqsave(&cosa->lock, flags); |
813 | if (signal_pending(current) && chan->rx_status == 0) { | 813 | if (signal_pending(current) && chan->rx_status == 0) { |
814 | chan->rx_status = 1; | 814 | chan->rx_status = 1; |
815 | remove_wait_queue(&chan->rxwaitq, &wait); | 815 | remove_wait_queue(&chan->rxwaitq, &wait); |
816 | current->state = TASK_RUNNING; | 816 | __set_current_state(TASK_RUNNING); |
817 | spin_unlock_irqrestore(&cosa->lock, flags); | 817 | spin_unlock_irqrestore(&cosa->lock, flags); |
818 | mutex_unlock(&chan->rlock); | 818 | mutex_unlock(&chan->rlock); |
819 | return -ERESTARTSYS; | 819 | return -ERESTARTSYS; |
820 | } | 820 | } |
821 | } | 821 | } |
822 | remove_wait_queue(&chan->rxwaitq, &wait); | 822 | remove_wait_queue(&chan->rxwaitq, &wait); |
823 | current->state = TASK_RUNNING; | 823 | __set_current_state(TASK_RUNNING); |
824 | kbuf = chan->rxdata; | 824 | kbuf = chan->rxdata; |
825 | count = chan->rxsize; | 825 | count = chan->rxsize; |
826 | spin_unlock_irqrestore(&cosa->lock, flags); | 826 | spin_unlock_irqrestore(&cosa->lock, flags); |
@@ -890,14 +890,14 @@ static ssize_t cosa_write(struct file *file, | |||
890 | spin_lock_irqsave(&cosa->lock, flags); | 890 | spin_lock_irqsave(&cosa->lock, flags); |
891 | add_wait_queue(&chan->txwaitq, &wait); | 891 | add_wait_queue(&chan->txwaitq, &wait); |
892 | while (!chan->tx_status) { | 892 | while (!chan->tx_status) { |
893 | current->state = TASK_INTERRUPTIBLE; | 893 | set_current_state(TASK_INTERRUPTIBLE); |
894 | spin_unlock_irqrestore(&cosa->lock, flags); | 894 | spin_unlock_irqrestore(&cosa->lock, flags); |
895 | schedule(); | 895 | schedule(); |
896 | spin_lock_irqsave(&cosa->lock, flags); | 896 | spin_lock_irqsave(&cosa->lock, flags); |
897 | if (signal_pending(current) && chan->tx_status == 0) { | 897 | if (signal_pending(current) && chan->tx_status == 0) { |
898 | chan->tx_status = 1; | 898 | chan->tx_status = 1; |
899 | remove_wait_queue(&chan->txwaitq, &wait); | 899 | remove_wait_queue(&chan->txwaitq, &wait); |
900 | current->state = TASK_RUNNING; | 900 | __set_current_state(TASK_RUNNING); |
901 | chan->tx_status = 1; | 901 | chan->tx_status = 1; |
902 | spin_unlock_irqrestore(&cosa->lock, flags); | 902 | spin_unlock_irqrestore(&cosa->lock, flags); |
903 | up(&chan->wsem); | 903 | up(&chan->wsem); |
@@ -905,7 +905,7 @@ static ssize_t cosa_write(struct file *file, | |||
905 | } | 905 | } |
906 | } | 906 | } |
907 | remove_wait_queue(&chan->txwaitq, &wait); | 907 | remove_wait_queue(&chan->txwaitq, &wait); |
908 | current->state = TASK_RUNNING; | 908 | __set_current_state(TASK_RUNNING); |
909 | up(&chan->wsem); | 909 | up(&chan->wsem); |
910 | spin_unlock_irqrestore(&cosa->lock, flags); | 910 | spin_unlock_irqrestore(&cosa->lock, flags); |
911 | kfree(kbuf); | 911 | kfree(kbuf); |