From: Bryn M. Reeves Date: Mon, 14 Mar 2016 21:04:34 +0000 (-0400) Subject: dm: fix rq_end_stats() NULL pointer in dm_requeue_original_request() X-Git-Tag: firefly_0821_release~176^2~4^2~50^2~159 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8907d8a6fd3f21992283efd67002aea719396f2b;p=firefly-linux-kernel-4.4.55.git dm: fix rq_end_stats() NULL pointer in dm_requeue_original_request() commit 98dbc9c6c61698792e3a66f32f3bf066201d42d7 upstream. An "old" (.request_fn) DM 'struct request' stores a pointer to the associated 'struct dm_rq_target_io' in rq->special. dm_requeue_original_request(), previously named dm_requeue_unmapped_original_request(), called dm_unprep_request() to reset rq->special to NULL. But rq_end_stats() would go on to hit a NULL pointer deference because its call to tio_from_request() returned NULL. Fix this by calling rq_end_stats() _before_ dm_unprep_request() Signed-off-by: Bryn M. Reeves Signed-off-by: Mike Snitzer Fixes: e262f34741 ("dm stats: add support for request-based DM devices") Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 887c6a11885b..c338aebb4ccd 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1210,9 +1210,9 @@ static void dm_requeue_original_request(struct mapped_device *md, { int rw = rq_data_dir(rq); + rq_end_stats(md, rq); dm_unprep_request(rq); - rq_end_stats(md, rq); if (!rq->q->mq_ops) old_requeue_request(rq); else {