浏览代码

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>
Maxim Levitsky 15 年之前
父节点
当前提交
12aebf3e1a
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      drivers/mtd/mtd_blkdevs.c

+ 4 - 0
drivers/mtd/mtd_blkdevs.c

@@ -133,6 +133,10 @@ static int mtd_blktrans_thread(void *arg)
 
 
 		if (!req && !(req = blk_fetch_request(rq))) {
 		if (!req && !(req = blk_fetch_request(rq))) {
 			set_current_state(TASK_INTERRUPTIBLE);
 			set_current_state(TASK_INTERRUPTIBLE);
+
+			if (kthread_should_stop())
+				set_current_state(TASK_RUNNING);
+
 			spin_unlock_irq(rq->queue_lock);
 			spin_unlock_irq(rq->queue_lock);
 			schedule();
 			schedule();
 			spin_lock_irq(rq->queue_lock);
 			spin_lock_irq(rq->queue_lock);