blk-mq: fix hctx/ctx kobject use-after-free
authorMing Lei <ming.lei@canonical.com>
Tue, 20 Jan 2015 03:00:56 +0000 (11:00 +0800)
committerJens Axboe <axboe@fb.com>
Tue, 20 Jan 2015 16:28:33 +0000 (09:28 -0700)
commit76d697d10769048e5721510100bf3a9413a56385
treee7d78afb91e9f7ff47f7e1e558f762908c50f49e
parent6222d1721dd7d533b43747642419a8ff78ad6f99
blk-mq: fix hctx/ctx kobject use-after-free

The kobject memory shouldn't have been freed before the kobject
is released because driver core can access it freely before its
release.

This patch frees hctx in its release callback. For ctx, they
share one single per-cpu variable which is associated with
the request queue, so free ctx in q->mq_kobj's release handler.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(fix ctx kobjects)
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq-sysfs.c
block/blk-mq.c