From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAA11352F8F; Tue, 6 Jan 2026 17:24:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767720243; cv=none; b=SK8HrnwRrGqacunPympAaLEci19PwxnMYYM3ss21G9ogIuRIBI8P8UD7cnrD7tJicdndhi+PvP1TQGN2TFE1BMDn6bswokGj7meq0092Q4wQftL55JFxcF91UKScZTMyVQn+WAlqOTTMa3wEqEKlurNqakT2a4XCzFCZ703l4Z8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767720243; c=relaxed/simple; bh=Q2S0B43sZEqJppGUVnEt1hTomTip1ViwmZA3JvA8mDY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t68IwW33gm5nSwVoyn/91eaSSr6GwW0iqJkQ7lSn31SRvlxTM+fYT540GdVlTGK5cTwT7+Uwu4E0oAjl+Jqbn/f3RlgqLPGHDCOjEkM+UuANSMy3UnUp6MTKTK6NLC3FcU+6madRgFxO+zoB33FzB9Lemjx7QuaLvP4a2fIgyGM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wV3X70IE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wV3X70IE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12006C16AAE; Tue, 6 Jan 2026 17:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767720242; bh=Q2S0B43sZEqJppGUVnEt1hTomTip1ViwmZA3JvA8mDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wV3X70IEKsb30tcecqzFYz7wrGjhKik19U03O18/w0ZOPsVY2XpluLsKnEMz+4dYI STzNyZuKIEmPRwvvi1a2KW9X9DmmfmmYi5MNib8ww9O1VdHABL7QaPDK7PlRcsQGU/ X2JRLMCxwjLDboS9eXx9SxJEB5ydzj2GNrFbHv5g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Justin Tee , Christoph Hellwig , Daniel Wagner , Keith Busch , Sasha Levin Subject: [PATCH 6.12 145/567] nvme-fc: dont hold rport lock when putting ctrl Date: Tue, 6 Jan 2026 17:58:47 +0100 Message-ID: <20260106170456.688007414@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260106170451.332875001@linuxfoundation.org> References: <20260106170451.332875001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Wagner [ Upstream commit b71cbcf7d170e51148d5467820ae8a72febcb651 ] 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 Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/host/fc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index d01bd3c300fa..3d90ace0b537 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -1462,14 +1462,14 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport, { struct fcnvme_ls_disconnect_assoc_rqst *rqst = &lsop->rqstbuf->rq_dis_assoc; - struct nvme_fc_ctrl *ctrl, *ret = NULL; + struct nvme_fc_ctrl *ctrl, *tmp, *ret = NULL; struct nvmefc_ls_rcv_op *oldls = NULL; u64 association_id = be64_to_cpu(rqst->associd.association_id); unsigned long flags; spin_lock_irqsave(&rport->lock, flags); - list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { + list_for_each_entry_safe(ctrl, tmp, &rport->ctrl_list, ctrl_list) { if (!nvme_fc_ctrl_get(ctrl)) continue; spin_lock(&ctrl->lock); @@ -1482,7 +1482,9 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport, if (ret) /* leave the ctrl get reference */ break; + spin_unlock_irqrestore(&rport->lock, flags); nvme_fc_ctrl_put(ctrl); + spin_lock_irqsave(&rport->lock, flags); } spin_unlock_irqrestore(&rport->lock, flags); -- 2.51.0