blk-mq: initialize 'struct request' and associated data to zero
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 9 Apr 2015 21:12:22 +0000 (14:12 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 11 Apr 2015 20:42:16 +0000 (13:42 -0700)
commitac2111753ca9350c8634c5d5f592628b32652cf3
tree6d662db69664afd6efda9c2570d22d056016f8ae
parent8fa5975900ba4e91e14a63f11fb7a026f60cecd5
blk-mq: initialize 'struct request' and associated data to zero

Jan Engelhardt reports a strange oops with an invalid ->sense_buffer
pointer in scsi_init_cmd_errh() with the blk-mq code.

The sense_buffer pointer should have been initialized by the call to
scsi_init_request() from blk_mq_init_rq_map(), but there seems to be
some non-repeatable memory corruptor.

This patch makes sure we initialize the whole struct request allocation
(and the associated 'struct scsi_cmnd' for the SCSI case) to zero, by
using __GFP_ZERO in the allocation.  The old code initialized a couple
of individual fields, leaving the rest undefined (although many of them
are then initialized in later phases, like blk_mq_rq_ctx_init() etc.

It's not entirely clear why this matters, but it's the rigth thing to do
regardless, and with 4.0 imminent this is the defensive "let's just make
sure everything is initialized properly" patch.

Tested-by: Jan Engelhardt <jengelh@inai.de>
Acked-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
block/blk-mq.c