Skip to content

Commit

Permalink
blk-mq: fix use-after-free of request
Browse files Browse the repository at this point in the history
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 <axboe@kernel.dk>
  • Loading branch information
ming1 authored and axboe committed Dec 5, 2013
1 parent 959a35f commit 0d11e6a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0d11e6a

Please sign in to comment.