Skip to content

Commit 682630f

Browse files
sagigrimbergChristoph Hellwig
authored andcommitted
nvme-rdma: fix possible double free of controller async event buffer
If reconnect/reset failed where the controller async event buffer was freed, we might end up freeing it again as we call nvme_rdma_destroy_admin_queue again in the remove path. Given that the sequence is guaranteed to serialize by .ctrl_stop, we simply set ctrl->async_event_sqe.data to NULL and don't free it in future visits. Reported-by: Max Gurtovoy <[email protected]> Tested-by: Max Gurtovoy <[email protected]> Signed-off-by: Sagi Grimberg <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 15bfd21 commit 682630f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/nvme/host/rdma.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,11 @@ static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl,
732732
blk_cleanup_queue(ctrl->ctrl.admin_q);
733733
nvme_rdma_free_tagset(&ctrl->ctrl, ctrl->ctrl.admin_tagset);
734734
}
735-
nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
736-
sizeof(struct nvme_command), DMA_TO_DEVICE);
735+
if (ctrl->async_event_sqe.data) {
736+
nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
737+
sizeof(struct nvme_command), DMA_TO_DEVICE);
738+
ctrl->async_event_sqe.data = NULL;
739+
}
737740
nvme_rdma_free_queue(&ctrl->queues[0]);
738741
}
739742

0 commit comments

Comments
 (0)