memstick: fix hangs on unexpected device removal in mspro_blk
authorMaxim Levitsky <maximlevitsky@gmail.com>
Wed, 11 Aug 2010 21:17:52 +0000 (14:17 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 26 Aug 2010 23:41:32 +0000 (16:41 -0700)
commit d862b13bc8cbab9692fbe0ef44c40d0488b81af1 upstream.

mspro_block_remove() is called from detect thread that first calls the
mspro_block_stop(), which stops the request queue.  If we call
del_gendisk() with the queue stopped we get a deadlock.

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Cc: Alex Dubov <oakad@yahoo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/memstick/core/mspro_block.c

index bd83fa0a4970fb13a5ddef788d1c68a5a7b21300..46bd7e2a952ceec89217323ac8f03ad032aa9803 100644 (file)
@@ -1330,13 +1330,14 @@ static void mspro_block_remove(struct memstick_dev *card)
        struct mspro_block_data *msb = memstick_get_drvdata(card);
        unsigned long flags;
 
-       del_gendisk(msb->disk);
-       dev_dbg(&card->dev, "mspro block remove\n");
        spin_lock_irqsave(&msb->q_lock, flags);
        msb->eject = 1;
        blk_start_queue(msb->queue);
        spin_unlock_irqrestore(&msb->q_lock, flags);
 
+       del_gendisk(msb->disk);
+       dev_dbg(&card->dev, "mspro block remove\n");
+
        blk_cleanup_queue(msb->queue);
        msb->queue = NULL;