Skip to content

Commit 9134ae2

Browse files
pspure78keithbusch
authored andcommitted
nvme-rdma: Avoid double freeing of async event data
The timeout of identify cmd, which is invoked as part of admin queue creation, can result in freeing of async event data both in nvme_rdma_timeout handler and error handling path of nvme_rdma_configure_admin queue thus causing NULL pointer reference. Call Trace: ? nvme_rdma_setup_ctrl+0x223/0x800 [nvme_rdma] nvme_rdma_create_ctrl+0x2ba/0x3f7 [nvme_rdma] nvmf_dev_write+0xa54/0xcc6 [nvme_fabrics] __vfs_write+0x1b/0x40 vfs_write+0xb2/0x1b0 ksys_write+0x61/0xd0 __x64_sys_write+0x1a/0x20 do_syscall_64+0x60/0x1e0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Reviewed-by: Roland Dreier <[email protected]> Reviewed-by: Max Gurtovoy <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Prabhath Sajeepa <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent dcd6589 commit 9134ae2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/nvme/host/rdma.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,9 +850,11 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,
850850
if (new)
851851
blk_mq_free_tag_set(ctrl->ctrl.admin_tagset);
852852
out_free_async_qe:
853-
nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
854-
sizeof(struct nvme_command), DMA_TO_DEVICE);
855-
ctrl->async_event_sqe.data = NULL;
853+
if (ctrl->async_event_sqe.data) {
854+
nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
855+
sizeof(struct nvme_command), DMA_TO_DEVICE);
856+
ctrl->async_event_sqe.data = NULL;
857+
}
856858
out_free_queue:
857859
nvme_rdma_free_queue(&ctrl->queues[0]);
858860
return error;

0 commit comments

Comments
 (0)