From patchwork Sat Oct 22 07:28:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1109984wrr; Sat, 22 Oct 2022 01:50:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mmogjgkmutV8exuUSlq8mK4uJGkKYUYSfo6AKWrGIM47blbDjJ7tlaeZHspGYXzmuTJeU X-Received: by 2002:a05:6402:5419:b0:457:c955:a40f with SMTP id ev25-20020a056402541900b00457c955a40fmr20669340edb.391.1666428652702; Sat, 22 Oct 2022 01:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428652; cv=none; d=google.com; s=arc-20160816; b=jjvsAci7etRtYxxJl1/fDHN+VYztF45GZs80I1jvo1jxupI5R7Hy5v/5X1qSpmwxWO fStX+2J2j95woF+maSx22DNnWWQLq66RqTiNNkisn6fmkoK4iXYPxVI52KIIgb/BibBa K8vfs3+ejJO4R1409ET6W5k2raeP2rjIZ9LBvv0Ve66BooUnw1DF9aJytUK5lsduIker hf+v2yzWTtWusrUCuFH/KWhUvV890FwHhQjfGCJNWN88Pbvv6X3HvaU2XlgsKoscLuVT M0KtfGIdeUE6z7XCpkYLD4xT3sTcwBKY/qe0/Funl3OelcGatSEP4HuLrRj6Q77Taruy RRKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nP+zCCEqeSPA4JQWBDFyMAt0mF7WHKpjyGjdsDTE5gc=; b=f2CE6KoM0s3ouA3RwqnJf1eSPRWoEuiUQirmuN/aq9HIsCqPbJ6AL9IXgKZyRmeFfy IPDqmjPmeNXp/kTsuH9m6wq3uKtTKe+VNHU8vUybqY/5JStAN6dRyMvMMhI7eAR09M89 +TVePXCWYrwLwR1ADvfofIEre8JR6jP/nGxX0q0Mky14l0KmG5O07AYBNm6QtFA372aP akPOaNOFc6II5DfXcWlcCpCudELnD3zCWSp5jlOQWNJ+6oibyoAynaM+LBcI1Xe5ke4Z mlA6k4VoMNDQJlGSjN1LKChlAv1Q0ISN0N+QLrNmH+nvwIgGiKi6hAB00Uc246IuQBYO XO/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kHcI2kDF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hw9-20020a170907a0c900b007a20c586f4esi430840ejc.876.2022.10.22.01.50.28; Sat, 22 Oct 2022 01:50:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kHcI2kDF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234909AbiJVItI (ORCPT + 99 others); Sat, 22 Oct 2022 04:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234886AbiJVIrV (ORCPT ); Sat, 22 Oct 2022 04:47:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A34E1B1F1; Sat, 22 Oct 2022 01:09:54 -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 ams.source.kernel.org (Postfix) with ESMTPS id A1A3EB82E0D; Sat, 22 Oct 2022 08:06:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D72F3C433D6; Sat, 22 Oct 2022 08:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666426003; bh=ZFoYiT9y2/iVY1FbCrXKpOhrfl3lZzZKHp9H5oPiBIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kHcI2kDFfhNbaZN/54J/hgEec2hb0d0fpSCfKCFs/mChB67bIiZyiZsMApG8kvWzd 3tD42fS1wGCtE030KqAeAnnBNT312MQc3Ym3eIhv/CFT/86jvwCnc8b83N14rfQM9C VWmIrB7vHT78OELjsz2qxKnGiLX9Dthgy6YUyOi4= 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 5.19 657/717] scsi: lpfc: Fix null ndlp ptr dereference in abnormal exit path for GFT_ID Date: Sat, 22 Oct 2022 09:28:56 +0200 Message-Id: <20221022072527.464672525@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747377091134412916?= X-GMAIL-MSGID: =?utf-8?q?1747377091134412916?= 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 = NULL; - struct lpfc_nodelist *ns_ndlp = NULL; + struct lpfc_nodelist *ns_ndlp = cmdiocb->ndlp; uint32_t fc4_data_0, fc4_data_1; u32 ulp_status = get_job_ulpstatus(phba, rspiocb); u32 ulp_word4 = get_job_word4(phba, rspiocb); @@ -1522,15 +1522,12 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ulp_status, ulp_word4, did); /* Ignore response if link flipped after this request was made */ - if ((uint32_t) cmdiocb->event_tag != phba->fc_eventTag) { + if ((uint32_t)cmdiocb->event_tag != phba->fc_eventTag) { lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, "9046 Event tag mismatch. Ignoring NS rsp\n"); goto out; } - /* Preserve the nameserver node to release the reference. */ - ns_ndlp = cmdiocb->ndlp; - if (ulp_status == IOSTAT_SUCCESS) { /* Good status, continue checking */ CTrsp = (struct lpfc_sli_ct_request *)outp->virt;