nvme-tcp: fix a NULL deref when an admin connect times out
authorSagi Grimberg <sagi@grimberg.me>
Wed, 24 Apr 2019 18:53:17 +0000 (11:53 -0700)
committerChristoph Hellwig <hch@lst.de>
Thu, 25 Apr 2019 14:51:37 +0000 (16:51 +0200)
If we timeout the admin startup sequence we might not yet have
an I/O tagset allocated which causes the teardown sequence to crash.
Make nvme_tcp_teardown_io_queues safe by not iterating inflight tags
if the tagset wasn't allocated.

Fixes: 39d57757467b ("nvme-tcp: fix timeout handler")
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/tcp.c

index 68c49dd672104d82ea768a6e9bf4354df731422b..aae5374d2b93ff0b9c318880fffbe8ac3b1f4b1a 100644 (file)
@@ -1710,7 +1710,9 @@ static void nvme_tcp_teardown_admin_queue(struct nvme_ctrl *ctrl,
 {
        blk_mq_quiesce_queue(ctrl->admin_q);
        nvme_tcp_stop_queue(ctrl, 0);
-       blk_mq_tagset_busy_iter(ctrl->admin_tagset, nvme_cancel_request, ctrl);
+       if (ctrl->admin_tagset)
+               blk_mq_tagset_busy_iter(ctrl->admin_tagset,
+                       nvme_cancel_request, ctrl);
        blk_mq_unquiesce_queue(ctrl->admin_q);
        nvme_tcp_destroy_admin_queue(ctrl, remove);
 }
@@ -1722,7 +1724,9 @@ static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl,
                return;
        nvme_stop_queues(ctrl);
        nvme_tcp_stop_io_queues(ctrl);
-       blk_mq_tagset_busy_iter(ctrl->tagset, nvme_cancel_request, ctrl);
+       if (ctrl->tagset)
+               blk_mq_tagset_busy_iter(ctrl->tagset,
+                       nvme_cancel_request, ctrl);
        if (remove)
                nvme_start_queues(ctrl);
        nvme_tcp_destroy_io_queues(ctrl, remove);