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

memstick: fix hangs on unexpected device removal in mspro_blk

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>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Maxim Levitsky and committed by
Linus Torvalds
d862b13b 21fd0495

+3 -2
+3 -2
drivers/memstick/core/mspro_block.c
··· 1339 1339 struct mspro_block_data *msb = memstick_get_drvdata(card); 1340 1340 unsigned long flags; 1341 1341 1342 - del_gendisk(msb->disk); 1343 - dev_dbg(&card->dev, "mspro block remove\n"); 1344 1342 spin_lock_irqsave(&msb->q_lock, flags); 1345 1343 msb->eject = 1; 1346 1344 blk_start_queue(msb->queue); 1347 1345 spin_unlock_irqrestore(&msb->q_lock, flags); 1346 + 1347 + del_gendisk(msb->disk); 1348 + dev_dbg(&card->dev, "mspro block remove\n"); 1348 1349 1349 1350 blk_cleanup_queue(msb->queue); 1350 1351 msb->queue = NULL;