blk-mq: fix use-after-free in blk_mq_free_tag_set()
authorJunichi Nomura <j-nomura@ce.jp.nec.com>
Wed, 14 Oct 2015 05:02:15 +0000 (05:02 +0000)
committerJens Axboe <axboe@fb.com>
Thu, 15 Oct 2015 14:45:58 +0000 (08:45 -0600)
commitf42d79ab67322e51b92dd7aa965e310c71352a64
tree33b6533d2b7c96502f73d34910bb0f34ec4e0bd7
parent835da3f99d329b1160a1f7fc82c7ac81163d63d0
blk-mq: fix use-after-free in blk_mq_free_tag_set()

tags is freed in blk_mq_free_rq_map() and should not be used after that.
The problem doesn't manifest if CONFIG_CPUMASK_OFFSTACK is false because
free_cpumask_var() is nop.

tags->cpumask is allocated in blk_mq_init_tags() so it's natural to
free cpumask in its counter part, blk_mq_free_tags().

Fixes: f26cdc8536ad ("blk-mq: Shared tag enhancements")
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: Keith Busch <keith.busch@intel.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq-tag.c
block/blk-mq.c