Skip to content

Commit 9ceb786

Browse files
israelruChristoph Hellwig
authored andcommitted
nvmet-rdma: Fix list_del corruption on queue establishment failure
When a queue is in NVMET_RDMA_Q_CONNECTING state, it may has some requests at rsp_wait_list. In case a disconnect occurs at this state, no one will empty this list and will return the requests to free_rsps list. Normally nvmet_rdma_queue_established() free those requests after moving the queue to NVMET_RDMA_Q_LIVE state, but in this case __nvmet_rdma_queue_disconnect() is called before. The crash happens at nvmet_rdma_free_rsps() when calling list_del(&rsp->free_list), because the request exists only at the wait list. To fix the issue, simply clear rsp_wait_list when destroying the queue. Signed-off-by: Israel Rukshin <israelr@nvidia.com> Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 9b66fc0 commit 9ceb786

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/nvme/target/rdma.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,16 @@ static void __nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue)
16411641
spin_lock_irqsave(&queue->state_lock, flags);
16421642
switch (queue->state) {
16431643
case NVMET_RDMA_Q_CONNECTING:
1644+
while (!list_empty(&queue->rsp_wait_list)) {
1645+
struct nvmet_rdma_rsp *rsp;
1646+
1647+
rsp = list_first_entry(&queue->rsp_wait_list,
1648+
struct nvmet_rdma_rsp,
1649+
wait_list);
1650+
list_del(&rsp->wait_list);
1651+
nvmet_rdma_put_rsp(rsp);
1652+
}
1653+
fallthrough;
16441654
case NVMET_RDMA_Q_LIVE:
16451655
queue->state = NVMET_RDMA_Q_DISCONNECTING;
16461656
disconnect = true;

0 commit comments

Comments
 (0)