diff options
author | Tejun Heo <tj@kernel.org> | 2011-11-03 13:52:11 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2011-11-03 13:52:11 -0400 |
commit | 6dd9ad7df2019b1e33a372a501907db293ebcd0d (patch) | |
tree | 1a07cfde1f3ea94b3f5f62e688d21668ff7831e4 /block | |
parent | 334c2b0b8b2ab186fa198413386cba41fffcb4f2 (diff) |
block: don't call blk_drain_queue() if elevator is not up
blk_cleanup_queue() may be called before elevator is set up on a
queue which triggers the following oops.
BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<ffffffff8125a69c>] elv_drain_elevator+0x1c/0x70
...
Pid: 830, comm: kworker/0:2 Not tainted 3.1.0-next-20111025_64+ #1590
Bochs Bochs
RIP: 0010:[<ffffffff8125a69c>] [<ffffffff8125a69c>] elv_drain_elevator+0x1c/0x70
...
Call Trace:
[<ffffffff8125da92>] blk_drain_queue+0x42/0x70
[<ffffffff8125db90>] blk_cleanup_queue+0xd0/0x1c0
[<ffffffff81469640>] md_free+0x50/0x70
[<ffffffff8126f43b>] kobject_release+0x8b/0x1d0
[<ffffffff81270d56>] kref_put+0x36/0xa0
[<ffffffff8126f2b7>] kobject_put+0x27/0x60
[<ffffffff814693af>] mddev_delayed_delete+0x2f/0x40
[<ffffffff81083450>] process_one_work+0x100/0x3b0
[<ffffffff8108527f>] worker_thread+0x15f/0x3a0
[<ffffffff81089937>] kthread+0x87/0x90
[<ffffffff81621834>] kernel_thread_helper+0x4/0x10
Fix it by making blk_cleanup_queue() check whether q->elevator is set
up before invoking blk_drain_queue.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-and-tested-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-core.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index f65871116404..f43c8a5840ae 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -407,8 +407,13 @@ void blk_cleanup_queue(struct request_queue *q) | |||
407 | spin_unlock_irq(lock); | 407 | spin_unlock_irq(lock); |
408 | mutex_unlock(&q->sysfs_lock); | 408 | mutex_unlock(&q->sysfs_lock); |
409 | 409 | ||
410 | /* drain all requests queued before DEAD marking */ | 410 | /* |
411 | blk_drain_queue(q, true); | 411 | * Drain all requests queued before DEAD marking. The caller might |
412 | * be trying to tear down @q before its elevator is initialized, in | ||
413 | * which case we don't want to call into draining. | ||
414 | */ | ||
415 | if (q->elevator) | ||
416 | blk_drain_queue(q, true); | ||
412 | 417 | ||
413 | /* @q won't process any more request, flush async actions */ | 418 | /* @q won't process any more request, flush async actions */ |
414 | del_timer_sync(&q->backing_dev_info.laptop_mode_wb_timer); | 419 | del_timer_sync(&q->backing_dev_info.laptop_mode_wb_timer); |