]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
block: Don't access request after it might be freed
authorRoland Dreier <roland@purestorage.com>
Thu, 22 Nov 2012 10:00:11 +0000 (02:00 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Dec 2012 19:37:59 +0000 (11:37 -0800)
commit1840c51ad1842d31d810a64425dc2b52492ba269
tree16af9ad325df8d10f4173d605310955ca5eb7fa7
parent36debf11e12044188601bf32b5e67d0d4a8b9373
block: Don't access request after it might be freed

commit 893d290f1d7496db97c9471bc352ad4a11dc8a25 upstream.

After we've done __elv_add_request() and __blk_run_queue() in
blk_execute_rq_nowait(), the request might finish and be freed
immediately.  Therefore checking if the type is REQ_TYPE_PM_RESUME
isn't safe afterwards, because if it isn't, rq might be gone.
Instead, check beforehand and stash the result in a temporary.

This fixes crashes in blk_execute_rq_nowait() I get occasionally when
running with lots of memory debugging options enabled -- I think this
race is usually harmless because the window for rq to be reallocated
is so small.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
block/blk-exec.c