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 B80DE2D5486; Mon, 5 May 2025 22:36:58 +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=1746484618; cv=none; b=nmbFWUdO/YxkP4pEMLLLRkGpGN6qEEbtGdD7iIF6mEr8s+3nYgt+iGNdX2cnkdlViH6bxv6AMH9PSiwVDO30T9Wuf2J2SZBVJVfPtjs4WI7NB8HkhlUTacGtaPK6AnQ3DykOVppdEEDmuT5743ARh3kZg6GO0owTXpANOgHIp0Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746484618; c=relaxed/simple; bh=H9FOgRwcMPrQx2C9zMW1osqc66AjCjqL/SIhMG/vmTw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mj9JEaxdequJuSlwruV1IDr93LkxPCh4xhWAYVozqn8cBVSf2uZ0vK1OQmdfYXnyUCsat2hUONJAyiLUwDiqYMrihlWt7ZFxC5ebJ9y0/FQNzrVJkpaZlgGVrwiRQEKgN5rRjHj+8id6n2pdy2uWI1oYEL+MD9Jc2UhH0RoWw0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L9uU7Vw1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L9uU7Vw1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32101C4CEED; Mon, 5 May 2025 22:36:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746484618; bh=H9FOgRwcMPrQx2C9zMW1osqc66AjCjqL/SIhMG/vmTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L9uU7Vw1upjDMPdaVCrIuGNr5Ko5fBGynl5xO+Whn4yjHi7I9xxX81oduFuDOonBe 8Pfio60y2Pm/XH4C+kozz4/c03g1AmIWGmY3lcPE0Jo9miOjfvVpdWJ+2293HXZMHj 3zRy9XvFhGSQwyJ4M7rCxPo/2qGD1ncpzP7QLgBfEzO5CuuS5o3CGG/c6W6y3IyByx oZV1qhz06PfoALtvYX7nVigGjfAbaF//jfWdcfWELyV2AdgZSiDTR89612iJ0QV9SA THN7T1XrBjf19NU4j1J7t+x4uBvBiOGwdFcdWeuxA3LRxKod+CUjICxry6EoqY55YE ESjWzrEyROkiw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Justin Tee , "Martin K . Petersen" , Sasha Levin , james.smart@broadcom.com, dick.kennedy@broadcom.com, James.Bottomley@HansenPartnership.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 6.14 564/642] scsi: lpfc: Handle duplicate D_IDs in ndlp search-by D_ID routine Date: Mon, 5 May 2025 18:13:00 -0400 Message-Id: <20250505221419.2672473-564-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505221419.2672473-1-sashal@kernel.org> References: <20250505221419.2672473-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.14.5 Content-Transfer-Encoding: 8bit From: Justin Tee [ Upstream commit 56c3d809b7b450379162d0b8a70bbe71ab8db706 ] After a port swap between separate fabrics, there may be multiple nodes in the vport's fc_nodes list with the same fabric well known address. Duplication is temporary and eventually resolves itself after dev_loss_tmo expires, but nameserver queries may still occur before dev_loss_tmo. This possibly results in returning stale fabric ndlp objects. Fix by adding an nlp_state check to ensure the ndlp search routine returns the correct newer allocated ndlp fabric object. Signed-off-by: Justin Tee Link: https://lore.kernel.org/r/20250131000524.163662-5-justintee8345@gmail.com Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc_hbadisc.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 36e66df36a18c..45d268d49060e 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -5564,6 +5564,7 @@ static struct lpfc_nodelist * __lpfc_findnode_did(struct lpfc_vport *vport, uint32_t did) { struct lpfc_nodelist *ndlp; + struct lpfc_nodelist *np = NULL; uint32_t data1; list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { @@ -5578,14 +5579,20 @@ __lpfc_findnode_did(struct lpfc_vport *vport, uint32_t did) ndlp, ndlp->nlp_DID, ndlp->nlp_flag, data1, ndlp->nlp_rpi, ndlp->active_rrqs_xri_bitmap); - return ndlp; + + /* Check for new or potentially stale node */ + if (ndlp->nlp_state != NLP_STE_UNUSED_NODE) + return ndlp; + np = ndlp; } } - /* FIND node did NOT FOUND */ - lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE, - "0932 FIND node did x%x NOT FOUND.\n", did); - return NULL; + if (!np) + /* FIND node did NOT FOUND */ + lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE, + "0932 FIND node did x%x NOT FOUND.\n", did); + + return np; } struct lpfc_nodelist * -- 2.39.5