linux/kernel/irq
Ido Yariv 550acb1926 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 <ido@wizery.com>
Link: http://lkml.kernel.org/r/1322740508-22640-1-git-send-email-ido@wizery.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@kernel.org
2011-12-02 11:54:24 +01:00
..
Kconfig irq: add irq_domain translation infrastructure 2011-07-28 01:32:04 -06:00
Makefile irq: add irq_domain translation infrastructure 2011-07-28 01:32:04 -06:00
autoprobe.c genirq: Remove compat code 2011-03-29 14:48:19 +02:00
chip.c genirq: Add support for per-cpu dev_id interrupts 2011-10-03 15:35:26 +02:00
debug.h genirq: Support per-IRQ thread disabling. 2011-04-23 15:56:24 +02:00
devres.c devres: fix possible use after free 2011-07-25 20:57:14 -07:00
dummychip.c genirq: Remove compat code 2011-03-29 14:48:19 +02:00
generic-chip.c kernel: Fix files explicitly needing EXPORT_SYMBOL infrastructure 2011-10-31 19:30:05 -04:00
handle.c irq: Handle spurios irq detection for threaded irqs 2011-06-03 14:53:15 +02:00
internals.h genirq: Add support for per-cpu dev_id interrupts 2011-10-03 15:35:26 +02:00
irqdesc.c irq: don't put module.h into irq.h for tracking irqgen modules. 2011-10-31 19:32:35 -04:00
irqdomain.c irq: support domains with non-zero hwirq base 2011-10-31 14:03:23 +01:00
manage.c genirq: Fix race condition when stopping the irq thread 2011-12-02 11:54:24 +01:00
migration.c Fix common misspellings 2011-03-31 11:26:23 -03:00
pm.c genirq: Add IRQF_RESUME_EARLY and resume such IRQs earlier 2011-10-17 11:42:49 +02:00
proc.c irq: Remove smp_affinity_list when unregister irq proc 2011-05-26 13:15:28 +02:00
resend.c genirq: Remove compat code 2011-03-29 14:48:19 +02:00
settings.h genirq: Add support for per-cpu dev_id interrupts 2011-10-03 15:35:26 +02:00
spurious.c genirq: fix regression in irqfixup, irqpoll 2011-11-28 08:43:09 -08:00