aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSagi Grimberg <sagi@grimberg.me>2017-10-19 09:00:30 -0400
committerChristoph Hellwig <hch@lst.de>2017-10-19 11:07:22 -0400
commitbd9f07590a17f3158b51fb869dca723f1f606bdc (patch)
treee7a19c5b8fd5bc31285c6ce7dcdf57ad062671ec
parentf9cf2a64912d67c9cf49c316a0a0ada0ea7ed1da (diff)
nvme-rdma: Fix possible double free in reconnect flow
The fact that we free the async event buffer in nvme_rdma_destroy_admin_queue can cause us to free it more than once because this happens in every reconnect attempt since commit 31fdf1840170. we rely on the queue state flags DELETING to avoid this for other resources. A more complete fix is to not destroy the admin/io queues unconditionally on every reconnect attempt, but its a bit more extensive and will go in the next release. Fixes: 31fdf1840170 ("nvme-rdma: reuse configure/destroy_admin_queue") Reported-by: Yi Zhang <yi.zhang@redhat.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/nvme/host/rdma.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 92a03ff5fb4d..4dbee893a047 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -571,6 +571,12 @@ static void nvme_rdma_free_queue(struct nvme_rdma_queue *queue)
571 if (test_and_set_bit(NVME_RDMA_Q_DELETING, &queue->flags)) 571 if (test_and_set_bit(NVME_RDMA_Q_DELETING, &queue->flags))
572 return; 572 return;
573 573
574 if (nvme_rdma_queue_idx(queue) == 0) {
575 nvme_rdma_free_qe(queue->device->dev,
576 &queue->ctrl->async_event_sqe,
577 sizeof(struct nvme_command), DMA_TO_DEVICE);
578 }
579
574 nvme_rdma_destroy_queue_ib(queue); 580 nvme_rdma_destroy_queue_ib(queue);
575 rdma_destroy_id(queue->cm_id); 581 rdma_destroy_id(queue->cm_id);
576} 582}
@@ -739,8 +745,6 @@ out:
739static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl, 745static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl,
740 bool remove) 746 bool remove)
741{ 747{
742 nvme_rdma_free_qe(ctrl->queues[0].device->dev, &ctrl->async_event_sqe,
743 sizeof(struct nvme_command), DMA_TO_DEVICE);
744 nvme_rdma_stop_queue(&ctrl->queues[0]); 748 nvme_rdma_stop_queue(&ctrl->queues[0]);
745 if (remove) { 749 if (remove) {
746 blk_cleanup_queue(ctrl->ctrl.admin_q); 750 blk_cleanup_queue(ctrl->ctrl.admin_q);