From: Maxim Levitsky Date: Fri, 15 Oct 2010 15:20:45 +0000 (+0200) Subject: mtd: blktrans: fix a race vs kthread_stop X-Git-Tag: upstream/snapshot3+hdmi~12564^2~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=12aebf3e1ad7dc8b076dd9674ca98f1aa6859fcd;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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 Signed-off-by: Artem Bityutskiy Signed-off-by: David Woodhouse --- diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 040c2d9..a919587 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -133,6 +133,10 @@ static int mtd_blktrans_thread(void *arg) if (!req && !(req = blk_fetch_request(rq))) { set_current_state(TASK_INTERRUPTIBLE); + + if (kthread_should_stop()) + set_current_state(TASK_RUNNING); + spin_unlock_irq(rq->queue_lock); schedule(); spin_lock_irq(rq->queue_lock);