From: Ming Lei Date: Thu, 5 Dec 2013 17:50:39 +0000 (-0700) Subject: blk-mq: fix use-after-free of request X-Git-Tag: upstream/snapshot3+hdmi~3827^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d11e6aca396e679c07b2dd6af5dc8b7f041fbbd;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git blk-mq: fix use-after-free of request If accounting is on, we will do the IO completion accounting after we have freed the request. Fix that by moving it sooner instead. Signed-off-by: Jens Axboe --- diff --git a/block/blk-mq.c b/block/blk-mq.c index 70fd6f9..c79126e 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -312,12 +312,12 @@ void blk_mq_complete_request(struct request *rq, int error) blk_account_io_completion(rq, bytes); + blk_account_io_done(rq); + if (rq->end_io) rq->end_io(rq, error); else blk_mq_free_request(rq); - - blk_account_io_done(rq); } void __blk_mq_end_io(struct request *rq, int error)