Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp309076pxb; Wed, 18 Nov 2020 05:15:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqEq12fi8cyXUBicrM52a4RGBl+QSVPQ5dtosT2e/gwbte/tfSIlzLvmuJZWQ9P5qEVdQX X-Received: by 2002:a17:906:1e0c:: with SMTP id g12mr23042170ejj.115.1605705355428; Wed, 18 Nov 2020 05:15:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605705355; cv=none; d=google.com; s=arc-20160816; b=cqnOz1rYO2PTHJIxMmuay6Emp/eo4lE965aOi9qBsP2NpdOMrcvzIOtpoodVGpRtsu 3dYU7rum7DVtHZkrfhRxNfjhXbrvupoK6NAvNp/rRCei3nkOVcEYOyCISN39qePHOp1A r6eoveMlvpo7YFr+kJE+zO1pMuctUAGppC9sqsnLaEjoFilecp9pyBquRUmbgk+1DGt4 aEPbUwC/UoaqhLRj0aFOE+3GmD/trXu23xdxl7gdTzpOBtgSTeApRZKGWv+v6eBtNA37 GwDsJgpr+2tW3HYCqRdGg6dg9Ed5Rg5lgH+DHK5uSENnX2rxqIpElVYh8+y/P6JVZDzt UpzQ== 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 :message-id:date:subject:cc:to:from; bh=n0jZktJZZUbiXPEeexnueK6QGkVQNHTKjH/56Jm/40E=; b=v78/CQ3Y99trAL8eYwKlMq9EvQ50JogYzT0WzKFz1ieH7ivdfG9G5cwsQhKWiaHyP2 6L9UFklDMG0VFV7rD5fmbYK5CdNNHC/2LKkn32LjvcXtkta8BWCMb2WB4pCeYeHhVN91 lGWl7vX7ajwH0Wy5PYpesmSkABY2571SlCXxpxSJGjUT5DNH4xuikc6hZs96Gma4S6xe 0if4WV9GRswR+sRlr3NOSa7Ru1a8zq8kgY4o2rLtuppPm6WSmnszr0DGwF15Dxo/eptm 1Akc55RLGpobln08fSnSefu1R8AEDwNf1Pvyvt8rJZpzA9YQfxmyGcbpZMZqMQ39ylkT FmMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d16si15627276edx.296.2020.11.18.05.15.32; Wed, 18 Nov 2020 05:15:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726274AbgKRNNt (ORCPT + 99 others); Wed, 18 Nov 2020 08:13:49 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:57997 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725772AbgKRNNt (ORCPT ); Wed, 18 Nov 2020 08:13:49 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kfNHN-0001Bz-Bc; Wed, 18 Nov 2020 13:13:45 +0000 From: Colin King To: James Smart , Dick Kennedy , "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] scsi: lpfc: fix pointer defereference before it is null checked issue Date: Wed, 18 Nov 2020 13:13:45 +0000 Message-Id: <20201118131345.460631-1-colin.king@canonical.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King There is a null check on pointer lpfc_cmd after the pointer has been dereferenced when pointers rdata and ndlp are initialized at the start of the function. Fix this by only assigning rdata and ndlp after the pointer lpfc_cmd has been null checked. Addresses-Coverity: ("Dereference before null check") Fixes: 96e209be6ecb ("scsi: lpfc: Convert SCSI I/O completions to SLI-3 and SLI-4 handlers") Signed-off-by: Colin Ian King --- drivers/scsi/lpfc/lpfc_scsi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index f989490359a5..3b989f720937 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -4022,8 +4022,8 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, struct lpfc_io_buf *lpfc_cmd = (struct lpfc_io_buf *)pwqeIn->context1; struct lpfc_vport *vport = pwqeIn->vport; - struct lpfc_rport_data *rdata = lpfc_cmd->rdata; - struct lpfc_nodelist *ndlp = rdata->pnode; + struct lpfc_rport_data *rdata; + struct lpfc_nodelist *ndlp; struct scsi_cmnd *cmd; unsigned long flags; struct lpfc_fast_path_event *fast_path_evt; @@ -4040,6 +4040,9 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, return; } + rdata = lpfc_cmd->rdata; + ndlp = rdata->pnode; + if (bf_get(lpfc_wcqe_c_xb, wcqe)) { /* TOREMOVE - currently this flag is checked during * the release of lpfc_iocbq. Remove once we move -- 2.28.0