Commit 2c45015a authored by Fabian Frederick's avatar Fabian Frederick Committed by David S. Miller

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: default avatarPeter Zijlstra <peterz@infradead.org>
Signed-off-by: default avatarFabian Frederick <fabf@skynet.be>
Acked-By: default avatarJan "Yenya" Kasprzak <kas@fi.muni.cz>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 50462ce0
...@@ -806,21 +806,21 @@ static ssize_t cosa_read(struct file *file, ...@@ -806,21 +806,21 @@ static ssize_t cosa_read(struct file *file,
spin_lock_irqsave(&cosa->lock, flags); spin_lock_irqsave(&cosa->lock, flags);
add_wait_queue(&chan->rxwaitq, &wait); add_wait_queue(&chan->rxwaitq, &wait);
while (!chan->rx_status) { while (!chan->rx_status) {
current->state = TASK_INTERRUPTIBLE; set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irqrestore(&cosa->lock, flags); spin_unlock_irqrestore(&cosa->lock, flags);
schedule(); schedule();
spin_lock_irqsave(&cosa->lock, flags); spin_lock_irqsave(&cosa->lock, flags);
if (signal_pending(current) && chan->rx_status == 0) { if (signal_pending(current) && chan->rx_status == 0) {
chan->rx_status = 1; chan->rx_status = 1;
remove_wait_queue(&chan->rxwaitq, &wait); remove_wait_queue(&chan->rxwaitq, &wait);
current->state = TASK_RUNNING; __set_current_state(TASK_RUNNING);
spin_unlock_irqrestore(&cosa->lock, flags); spin_unlock_irqrestore(&cosa->lock, flags);
mutex_unlock(&chan->rlock); mutex_unlock(&chan->rlock);
return -ERESTARTSYS; return -ERESTARTSYS;
} }
} }
remove_wait_queue(&chan->rxwaitq, &wait); remove_wait_queue(&chan->rxwaitq, &wait);
current->state = TASK_RUNNING; __set_current_state(TASK_RUNNING);
kbuf = chan->rxdata; kbuf = chan->rxdata;
count = chan->rxsize; count = chan->rxsize;
spin_unlock_irqrestore(&cosa->lock, flags); spin_unlock_irqrestore(&cosa->lock, flags);
...@@ -890,14 +890,14 @@ static ssize_t cosa_write(struct file *file, ...@@ -890,14 +890,14 @@ static ssize_t cosa_write(struct file *file,
spin_lock_irqsave(&cosa->lock, flags); spin_lock_irqsave(&cosa->lock, flags);
add_wait_queue(&chan->txwaitq, &wait); add_wait_queue(&chan->txwaitq, &wait);
while (!chan->tx_status) { while (!chan->tx_status) {
current->state = TASK_INTERRUPTIBLE; set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irqrestore(&cosa->lock, flags); spin_unlock_irqrestore(&cosa->lock, flags);
schedule(); schedule();
spin_lock_irqsave(&cosa->lock, flags); spin_lock_irqsave(&cosa->lock, flags);
if (signal_pending(current) && chan->tx_status == 0) { if (signal_pending(current) && chan->tx_status == 0) {
chan->tx_status = 1; chan->tx_status = 1;
remove_wait_queue(&chan->txwaitq, &wait); remove_wait_queue(&chan->txwaitq, &wait);
current->state = TASK_RUNNING; __set_current_state(TASK_RUNNING);
chan->tx_status = 1; chan->tx_status = 1;
spin_unlock_irqrestore(&cosa->lock, flags); spin_unlock_irqrestore(&cosa->lock, flags);
up(&chan->wsem); up(&chan->wsem);
...@@ -905,7 +905,7 @@ static ssize_t cosa_write(struct file *file, ...@@ -905,7 +905,7 @@ static ssize_t cosa_write(struct file *file,
} }
} }
remove_wait_queue(&chan->txwaitq, &wait); remove_wait_queue(&chan->txwaitq, &wait);
current->state = TASK_RUNNING; __set_current_state(TASK_RUNNING);
up(&chan->wsem); up(&chan->wsem);
spin_unlock_irqrestore(&cosa->lock, flags); spin_unlock_irqrestore(&cosa->lock, flags);
kfree(kbuf); kfree(kbuf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment