From nobody Fri Oct 17 12:03:00 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2D69C433FE for ; Wed, 19 Oct 2022 12:32:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231791AbiJSMcD (ORCPT ); Wed, 19 Oct 2022 08:32:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231265AbiJSMbk (ORCPT ); Wed, 19 Oct 2022 08:31:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AFF44A803; Wed, 19 Oct 2022 05:09:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1E41F617DE; Wed, 19 Oct 2022 09:13:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23FA6C433C1; Wed, 19 Oct 2022 09:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170819; bh=ZFoYiT9y2/iVY1FbCrXKpOhrfl3lZzZKHp9H5oPiBIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dxAI15kNBHcTff1TM8GBU3CoAtLYmSgp5D7UBVyKwb90kgHPNSMTAm0u4dO5toGMD 4YqbKkPXXPbgPRPUAwoJF7GApKCXY6zDNtV+g9/ErMjKbJowMiHFmQszSyzFIiRyhU 546EiygB7NEbi1CO+VB1eQkQfA9GRkNe0l8oN8tE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Justin Tee , James Smart , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 6.0 799/862] scsi: lpfc: Fix null ndlp ptr dereference in abnormal exit path for GFT_ID Date: Wed, 19 Oct 2022 10:34:46 +0200 Message-Id: <20221019083325.204708073@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: James Smart [ Upstream commit 59b7e210a522b836a01516c71ee85d1d92c1f075 ] An error case exit from lpfc_cmpl_ct_cmd_gft_id() results in a call to lpfc_nlp_put() with a null pointer to a nodelist structure. Changed lpfc_cmpl_ct_cmd_gft_id() to initialize nodelist pointer upon entry. Link: https://lore.kernel.org/r/20220819011736.14141-3-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc_ct.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index 13dfe285493d..b555ccb5ae34 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -1509,7 +1509,7 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct= lpfc_iocbq *cmdiocb, struct lpfc_sli_ct_request *CTrsp; int did; struct lpfc_nodelist *ndlp =3D NULL; - struct lpfc_nodelist *ns_ndlp =3D NULL; + struct lpfc_nodelist *ns_ndlp =3D cmdiocb->ndlp; uint32_t fc4_data_0, fc4_data_1; u32 ulp_status =3D get_job_ulpstatus(phba, rspiocb); u32 ulp_word4 =3D get_job_word4(phba, rspiocb); @@ -1522,15 +1522,12 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, stru= ct lpfc_iocbq *cmdiocb, ulp_status, ulp_word4, did); =20 /* Ignore response if link flipped after this request was made */ - if ((uint32_t) cmdiocb->event_tag !=3D phba->fc_eventTag) { + if ((uint32_t)cmdiocb->event_tag !=3D phba->fc_eventTag) { lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, "9046 Event tag mismatch. Ignoring NS rsp\n"); goto out; } =20 - /* Preserve the nameserver node to release the reference. */ - ns_ndlp =3D cmdiocb->ndlp; - if (ulp_status =3D=3D IOSTAT_SUCCESS) { /* Good status, continue checking */ CTrsp =3D (struct lpfc_sli_ct_request *)outp->virt; --=20 2.35.1