diff options
| author | Ido Yariv <[email protected]> | 2011-12-01 11:55:08 +0000 |
|---|---|---|
| committer | Thomas Gleixner <[email protected]> | 2011-12-02 10:54:24 +0000 |
| commit | 550acb19269d65f32e9ac4ddb26c2b2070e37f1c (patch) | |
| tree | 804925b363142e47a4a26f1afcfb8f9e302bed0e /fs/btrfs/async-thread.c | |
| parent | Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mas... (diff) | |
| download | kernel-550acb19269d65f32e9ac4ddb26c2b2070e37f1c.tar.gz kernel-550acb19269d65f32e9ac4ddb26c2b2070e37f1c.zip | |
genirq: Fix race condition when stopping the irq thread
In irq_wait_for_interrupt(), the should_stop member is verified before
setting the task's state to TASK_INTERRUPTIBLE and calling schedule().
In case kthread_stop sets should_stop and wakes up the process after
should_stop is checked by the irq thread but before the task's state
is changed, the irq thread might never exit:
kthread_stop irq_wait_for_interrupt
------------ ----------------------
...
... while (!kthread_should_stop()) {
kthread->should_stop = 1;
wake_up_process(k);
wait_for_completion(&kthread->exited);
...
set_current_state(TASK_INTERRUPTIBLE);
...
schedule();
}
Fix this by checking if the thread should stop after modifying the
task's state.
[ tglx: Simplified it a bit ]
Signed-off-by: Ido Yariv <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: [email protected]
Diffstat (limited to 'fs/btrfs/async-thread.c')
0 files changed, 0 insertions, 0 deletions
