mtd: blktrans: fix a race vs kthread_stop

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun Oct 24 20:59:11 EDT 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=12aebf3e1ad7dc8b076dd9674ca98f1aa6859fcd
Commit:     12aebf3e1ad7dc8b076dd9674ca98f1aa6859fcd
Parent:     480792b7bf188c29b8d4b10fee65c3a06ec5dbf7
Author:     Maxim Levitsky <maximlevitsky at gmail.com>
AuthorDate: Fri Oct 15 17:20:45 2010 +0200
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Oct 25 01:28:52 2010 +0100

    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 at gmail.com>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtd_blkdevs.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

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);



More information about the linux-mtd-cvs mailing list