nvme-rdma: fix possible use-after-free in connect timeout
authorSagi Grimberg <sagi@grimberg.me>
Tue, 24 Sep 2019 18:27:05 +0000 (11:27 -0700)
committerSagi Grimberg <sagi@grimberg.me>
Fri, 27 Sep 2019 17:24:53 +0000 (10:24 -0700)
If the connect times out, we may have already destroyed the
queue in the timeout handler, so test if the queue is still
allocated in the connect error handler.

Reported-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
drivers/nvme/host/rdma.c

index 9d16dfc29368a8a53655331ffa78897f498b210c..4d280160dd3fd32608b5d4e9a7b699646adcdaf8 100644 (file)
@@ -620,7 +620,8 @@ static int nvme_rdma_start_queue(struct nvme_rdma_ctrl *ctrl, int idx)
        if (!ret) {
                set_bit(NVME_RDMA_Q_LIVE, &queue->flags);
        } else {
-               __nvme_rdma_stop_queue(queue);
+               if (test_bit(NVME_RDMA_Q_ALLOCATED, &queue->flags))
+                       __nvme_rdma_stop_queue(queue);
                dev_info(ctrl->ctrl.device,
                        "failed to connect queue: %d ret=%d\n", idx, ret);
        }