Since commit 2a8513091d2f ("nvme-rdma: parallelize I/O queue allocation and startup"), the error path of nvme_rdma_setup_io_queues() frees the queues of the batch. The caller cancels the outstanding requests only afterwards. This matters on a reconnect. Error recovery leaves the I/O queues unquiesced, so a queue that went live can have requests in flight when another queue of the same batch fails. The QP and the MR pools of the live queue are then freed under those requests. When nvme_cancel_tagset() completes them, each request with a registered MR ends up in ib_mr_pool_put() on the freed QP. Only stop the queues in the unwind, as nvme_rdma_start_io_queues() did before that commit. The caller already calls nvme_rdma_free_io_queues() after it has cancelled the requests. Fixes: 2a8513091d2f ("nvme-rdma: parallelize I/O queue allocation and startup") Cc: stable@vger.kernel.org Signed-off-by: Stephane Thiell --- Found by code review, not reproduced. Build-tested (W=1) on v7.4-rc3-602-g5f22fb20497f only. drivers/nvme/host/rdma.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 32189fdfc0f5..c45e45dec287 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -748,19 +748,13 @@ static int nvme_rdma_setup_io_queues(struct nvme_rdma_ctrl *ctrl, ret = READ_ONCE(err); if (ret) - goto out_free_queues; + goto out_stop_queues; return 0; -out_free_queues: - for (i = 0; i < nr_queues; i++) { - struct nvme_rdma_queue *queue = - &ctrl->queues[first + i]; - - if (test_bit(NVME_RDMA_Q_LIVE, &queue->flags)) - nvme_rdma_stop_queue(queue); - if (test_bit(NVME_RDMA_Q_ALLOCATED, &queue->flags)) - nvme_rdma_free_queue(queue); - } +out_stop_queues: + /* don't free here: requests may still be outstanding */ + for (i = 0; i < nr_queues; i++) + nvme_rdma_stop_queue(&ctrl->queues[first + i]); return ret; } base-commit: 5f22fb20497f4983094131f00a734362300d22d2 -- 2.39.1