Skip to content

Commit 43b92fd

Browse files
Israel Rukshinaxboe
authored andcommitted
nvmet-rdma: update queue list during ib_device removal
A NULL deref happens when nvmet_rdma_remove_one() is called more than once (e.g. while connected via 2 ports). The first call frees the queues related to the first ib_device but doesn't remove them from the queue list. While calling nvmet_rdma_remove_one() for the second ib_device it goes over the full queue list again and we get the NULL deref. Fixes: f1d4ef7 ("nvmet-rdma: register ib_client to not deadlock in device removal") Signed-off-by: Israel Rukshin <israelr@mellanox.com> Reviewed-by: Max Gurtovoy <maxg@mellanox.com> Reviewed-by: Sagi Grimberg <sagi@grmberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 6ddcf0a commit 43b92fd

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎drivers/nvme/target/rdma.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,15 +1512,17 @@ static struct nvmet_fabrics_ops nvmet_rdma_ops = {
15121512

15131513
static void nvmet_rdma_remove_one(struct ib_device *ib_device, void *client_data)
15141514
{
1515-
struct nvmet_rdma_queue *queue;
1515+
struct nvmet_rdma_queue *queue, *tmp;
15161516

15171517
/* Device is being removed, delete all queues using this device */
15181518
mutex_lock(&nvmet_rdma_queue_mutex);
1519-
list_for_each_entry(queue, &nvmet_rdma_queue_list, queue_list) {
1519+
list_for_each_entry_safe(queue, tmp, &nvmet_rdma_queue_list,
1520+
queue_list) {
15201521
if (queue->dev->device != ib_device)
15211522
continue;
15221523

15231524
pr_info("Removing queue %d\n", queue->idx);
1525+
list_del_init(&queue->queue_list);
15241526
__nvmet_rdma_queue_disconnect(queue);
15251527
}
15261528
mutex_unlock(&nvmet_rdma_queue_mutex);

0 commit comments

Comments
 (0)