nvme-loop: fix a possible use-after-free when destroying the admin queue
authorSagi Grimberg <sagi@grimberg.me>
Mon, 27 Feb 2017 16:44:45 +0000 (18:44 +0200)
committerJens Axboe <axboe@fb.com>
Tue, 4 Apr 2017 15:44:41 +0000 (09:44 -0600)
we need to destroy the nvmet sq and let it finish gracefully
before continue to cleanup the queue.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
drivers/nvme/target/loop.c

index 4bfb285c32e812b234d04555677e2de99fd40d2c..f880b8b8495a0120af0022c2af8200610c2af91b 100644 (file)
@@ -288,9 +288,9 @@ static const struct blk_mq_ops nvme_loop_admin_mq_ops = {
 
 static void nvme_loop_destroy_admin_queue(struct nvme_loop_ctrl *ctrl)
 {
+       nvmet_sq_destroy(&ctrl->queues[0].nvme_sq);
        blk_cleanup_queue(ctrl->ctrl.admin_q);
        blk_mq_free_tag_set(&ctrl->admin_tag_set);
-       nvmet_sq_destroy(&ctrl->queues[0].nvme_sq);
 }
 
 static void nvme_loop_free_ctrl(struct nvme_ctrl *nctrl)