Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp133044rwi; Wed, 12 Oct 2022 17:19:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5SnyyCE/27PSn6L5gUszmjLbUFBy+kCSa+XZnh9iH+JmZMAe8ER1wE675s1pPEqy0LiZUJ X-Received: by 2002:a17:907:1dc7:b0:78d:c153:d64a with SMTP id og7-20020a1709071dc700b0078dc153d64amr11992817ejc.429.1665620381966; Wed, 12 Oct 2022 17:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665620381; cv=none; d=google.com; s=arc-20160816; b=bbVZv13bKoFPOZGx7r+axixsx65Hnd1Hgl6TYGTb7tX84/V7vTo4n1XlO/GuF9c0Eh rm7zYhlZd835wYL+FJq8gvLMtoEphlhBZooSqoSgkeWk/3DIqITCpxokE6sVann4xmLR qU3/kSdnKXaMkN3n4mXMUlkuj/IgtN1p1BZ0dpRHmDhiD1BUnSY/Ac3MkNjs9czvnJma 2In5IN97i/P92MKxhMp4CVH+FpCGupToEQiA0e8nMmnIR5x67iBD1WTaYrY3fNS9bzyt T0yBVv4O+J77HIJlxAPo5DZhLhG4f/yQrqebvQilBQ+PZ4ZUbCJBuTtUrrN8VfcOhuaE eNCA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nP+zCCEqeSPA4JQWBDFyMAt0mF7WHKpjyGjdsDTE5gc=; b=qITCUBASfjULiLw7w8IBLQllFs/pZ7Y0M+lWsNdzo1evbkkrAusYb/+gY6FbgiV1by 32AgYpuHYGqSzEOcJT6WxgZBOA8ewGDSqp1bzz/0AO6UUZ/j5NXZcCLl2Po01GdRg9/6 N7wl5YeeY6558AoG6MgNFBms+xOln2BX67A8y1x4coE7dBl4ZPGYytgB74gaVXwQJWNP xY1yzYrNjNFa29jSQ585k2fxHW2AAqevDGXUAdE6vXAc3DRYxqJeIXAFhhhIMRAoIr46 rdeqtucJ1PbpRhEFmQdaTehAjQPTV65oVl/+WXiehn4USyoS95zjLyrhRzJdJx6EkqfJ Htjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b8Z14IVL; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz30-20020a1709077d9e00b0078cf86b12e5si17311010ejc.221.2022.10.12.17.19.14; Wed, 12 Oct 2022 17:19:41 -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=@kernel.org header.s=k20201202 header.b=b8Z14IVL; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbiJMAQy (ORCPT + 99 others); Wed, 12 Oct 2022 20:16:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbiJMAQk (ORCPT ); Wed, 12 Oct 2022 20:16:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E78FE93A; Wed, 12 Oct 2022 17:16:18 -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 DB615616B6; Thu, 13 Oct 2022 00:16:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CE00C4347C; Thu, 13 Oct 2022 00:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665620177; bh=ZFoYiT9y2/iVY1FbCrXKpOhrfl3lZzZKHp9H5oPiBIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8Z14IVL7CfZzk6Ahtqgdg8M/VOM4VZ67pRLuAzbNM6bGsCqXWxS+81l7lF9TTmRk dYtSpTmHY5YC+8TWI1QbhsPPeuPH+CRhWnKaaeMUdrmicgIvxxb4wvW27GLZ5Yjc2C STh/JVJQ7ZqcAGfsqTYsD1ZO59iQtFz4sDVDJ30WC4pOdV9Poeqvy34doKtCrgt4S/ dmwicrHUwT0Ar09MrQK5XPKFjA1tdEqB+u3Sag1Wu8B3R/chpQShphK14PQXfOk3OQ q0EDanZVHL8kovQxThtywQCWT1h0jFREGIQzOhHpJ/dqR2Rluu8DX6h6w8ZwyKtdNz 6cc2fU4CN4tfg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: James Smart , Justin Tee , "Martin K . Petersen" , Sasha Levin , james.smart@broadcom.com, dick.kennedy@broadcom.com, jejb@linux.ibm.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 09/67] scsi: lpfc: Fix null ndlp ptr dereference in abnormal exit path for GFT_ID Date: Wed, 12 Oct 2022 20:14:50 -0400 Message-Id: <20221013001554.1892206-9-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221013001554.1892206-1-sashal@kernel.org> References: <20221013001554.1892206-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 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; -- 2.35.1