If a device disappears, the elevator may in some cases be used after free, similar to 0a58e077eb600d1efd7e54ad9926a75a39d7f8ae Several crashes were seen with the trace [] elv_drain_elevator+0x17/0x60 [] elv_insert+0x129/0x260 [] blk_insert_cloned_request+0x53/0x70 [] dm_dispatch_request+0x2f/0x60 [dm_mod] [] dispatch_queued_ios+0x110/0x150 [dm_multipath] [] run_workqueue+0xa3/0x1f0 [] worker_thread+0x96/0x110 [] kthread+0x96/0xa0 [] child_rip+0xa/0x20 This patch adds more tests to ensure a dead queue isn't used Signed-off-by: Anders Johansson diff -upr a/block/elevator.c b/block/elevator.c --- a/block/elevator.c 2011-08-24 18:44:20.000000000 +0200 +++ b/block/elevator.c 2011-09-05 15:04:08.000000000 +0200 @@ -622,7 +622,7 @@ void elv_drain_elevator(struct request_q */ void elv_quiesce_start(struct request_queue *q) { - if (!q->elevator) + if (!q->elevator || test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)) return; queue_flag_set(QUEUE_FLAG_ELVSWITCH, q); @@ -649,6 +649,9 @@ void elv_insert(struct request_qu { trace_block_rq_insert(q, rq); + if(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)) + return; + rq->q = q; if (rq->cmd_flags & REQ_SOFTBARRIER) {