Skip to content

Commit b71cbcf

Browse files
igawkeithbusch
authored andcommitted
nvme-fc: don't hold rport lock when putting ctrl
nvme_fc_ctrl_put can acquire the rport lock when freeing the ctrl object: nvme_fc_ctrl_put nvme_fc_ctrl_free spin_lock_irqsave(rport->lock) Thus we can't hold the rport lock when calling nvme_fc_ctrl_put. Justin suggested use the safe list iterator variant because nvme_fc_ctrl_put will also modify the rport->list. Cc: Justin Tee <justin.tee@broadcom.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Daniel Wagner <wagi@kernel.org> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 78723fe commit b71cbcf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • drivers/nvme/host

drivers/nvme/host/fc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,14 +1468,14 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport,
14681468
{
14691469
struct fcnvme_ls_disconnect_assoc_rqst *rqst =
14701470
&lsop->rqstbuf->rq_dis_assoc;
1471-
struct nvme_fc_ctrl *ctrl, *ret = NULL;
1471+
struct nvme_fc_ctrl *ctrl, *tmp, *ret = NULL;
14721472
struct nvmefc_ls_rcv_op *oldls = NULL;
14731473
u64 association_id = be64_to_cpu(rqst->associd.association_id);
14741474
unsigned long flags;
14751475

14761476
spin_lock_irqsave(&rport->lock, flags);
14771477

1478-
list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) {
1478+
list_for_each_entry_safe(ctrl, tmp, &rport->ctrl_list, ctrl_list) {
14791479
if (!nvme_fc_ctrl_get(ctrl))
14801480
continue;
14811481
spin_lock(&ctrl->lock);
@@ -1488,7 +1488,9 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport,
14881488
if (ret)
14891489
/* leave the ctrl get reference */
14901490
break;
1491+
spin_unlock_irqrestore(&rport->lock, flags);
14911492
nvme_fc_ctrl_put(ctrl);
1493+
spin_lock_irqsave(&rport->lock, flags);
14921494
}
14931495

14941496
spin_unlock_irqrestore(&rport->lock, flags);

0 commit comments

Comments
 (0)