Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: blktrans: fix a race vs kthread_stop

There is small race window that could make kthread_stop hang forever.
I found that while hacking the IR subsystem.

Signed-off-by: Maxim Levitsky <maximlevisky@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Maxim Levitsky and committed by
David Woodhouse
12aebf3e 480792b7

+4
+4
drivers/mtd/mtd_blkdevs.c
··· 133 133 134 134 if (!req && !(req = blk_fetch_request(rq))) { 135 135 set_current_state(TASK_INTERRUPTIBLE); 136 + 137 + if (kthread_should_stop()) 138 + set_current_state(TASK_RUNNING); 139 + 136 140 spin_unlock_irq(rq->queue_lock); 137 141 schedule(); 138 142 spin_lock_irq(rq->queue_lock);