linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Smart <james.smart@broadcom.com>
To: linux-scsi@vger.kernel.org
Cc: James Smart <james.smart@broadcom.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH] lpfc: Correct null ndlp reference on routine exit
Date: Mon, 30 Nov 2020 10:12:26 -0800	[thread overview]
Message-ID: <20201130181226.16675-1-james.smart@broadcom.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1470 bytes --]

smatch correctly called out a logic error with accessing a pointer after
checking it for null.
 drivers/scsi/lpfc/lpfc_els.c:2043 lpfc_cmpl_els_plogi()
 error: we previously assumed 'ndlp' could be null (see line 1942)

Adjust the exit point to avoid the trace printf ndlp reference. A trace
entry was already generated when the ndlp was checked for null.

Fixes: 4430f7fd09ec ("scsi: lpfc: Rework locations of ndlp reference taking")
Signed-off-by: James Smart <james.smart@broadcom.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/scsi/lpfc/lpfc_els.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index fd5c581cd67a..96c087b8b474 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -1946,7 +1946,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 				 irsp->un.elsreq64.remoteID,
 				 irsp->ulpStatus, irsp->un.ulpWord[4],
 				 irsp->ulpIoTag);
-		goto out;
+		goto out_freeiocb;
 	}
 
 	/* Since ndlp can be freed in the disc state machine, note if this node
@@ -2042,6 +2042,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 			      "PLOGI Cmpl PUT:     did:x%x refcnt %d",
 			      ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
 
+out_freeiocb:
 	/* Release the reference on the original I/O request. */
 	free_ndlp = (struct lpfc_nodelist *)cmdiocb->context1;
 
-- 
2.26.2


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4163 bytes --]

             reply	other threads:[~2020-11-30 18:13 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 18:12 James Smart [this message]
     [not found] ` <(James>
2020-12-08  4:52 ` [PATCH] lpfc: Correct null ndlp reference on routine exit Martin K. Petersen
     [not found] <CGME20201207190149epcas5p2d877f4e3f6d31548d97f9b486d243a05@epcas5p2.samsung.com>
2020-12-07 19:01 ` [PATCH 0/2] two UFS changes Bean Huo
     [not found]   ` <(Bean>
2020-12-07 19:01   ` [PATCH 1/2] scsi: ufs: Remove an unused macro definition POWER_DESC_MAX_SIZE Bean Huo
2020-12-08  7:52     ` Avri Altman
2020-12-07 19:01   ` [PATCH 2/2] scsi: ufs: Fix wrong print message in dev_err() Bean Huo
2020-12-08  7:53     ` Avri Altman
2020-12-08  2:57   ` [PATCH 0/2] two UFS changes Alim Akhtar
  -- strict thread matches above, loose matches on Subject: below --
2020-05-12  8:55 [PATCH v11 00/10] Introduce Zone Append for writing to zoned block devices Johannes Thumshirn
2020-05-12  8:55 ` [PATCH v11 01/10] block: provide fallbacks for blk_queue_zone_is_seq and blk_queue_zone_no Johannes Thumshirn
2020-05-12  8:55 ` [PATCH v11 02/10] block: rename __bio_add_pc_page to bio_add_hw_page Johannes Thumshirn
2020-05-12  8:55 ` [PATCH v11 03/10] block: Introduce REQ_OP_ZONE_APPEND Johannes Thumshirn
2020-05-12  8:55 ` [PATCH v11 04/10] block: introduce blk_req_zone_write_trylock Johannes Thumshirn
2020-05-12  8:55 ` [PATCH v11 05/10] block: Modify revalidate zones Johannes Thumshirn
2020-05-12  8:55 ` [PATCH v11 06/10] scsi: sd_zbc: factor out sanity checks for zoned commands Johannes Thumshirn
2020-05-12  8:55 ` [PATCH v11 07/10] scsi: sd_zbc: emulate ZONE_APPEND commands Johannes Thumshirn
2020-05-12  8:55 ` [PATCH v11 08/10] null_blk: Support REQ_OP_ZONE_APPEND Johannes Thumshirn
2020-05-12  8:55 ` [PATCH v11 09/10] block: export bio_release_pages and bio_iov_iter_get_pages Johannes Thumshirn
2020-05-12  8:55 ` [PATCH v11 10/10] zonefs: use REQ_OP_ZONE_APPEND for sync DIO Johannes Thumshirn
2020-05-12 13:17 ` [PATCH v11 00/10] Introduce Zone Append for writing to zoned block devices Christoph Hellwig
     [not found]   ` <(Christoph>
2020-05-13  2:37 ` Jens Axboe
2015-12-03  6:57 [PATCH] scsi_dh_alua: Remove stale variables Hannes Reinecke
2015-12-03  9:23 ` Johannes Thumshirn
2015-12-03 16:43 ` Christoph Hellwig
     [not found] ` <(Hannes>
     [not found]   ` <Reinecke's>
     [not found]     ` <message>
     [not found]       ` <of>
     [not found]         ` <"Mon>
     [not found]           ` <30>
     [not found]         ` <"Tue>
     [not found]           ` <12>
     [not found]             ` <May>
     [not found]               ` <2020>
     [not found]                 ` <06:17:48>
     [not found]                   ` <-0700")>
2020-05-12 16:01                     ` [PATCH v11 00/10] Introduce Zone Append for writing to zoned block devices Martin K. Petersen
2020-05-12 16:04                       ` Christoph Hellwig
2020-05-12 16:12                         ` Martin K. Petersen
2020-05-12 16:18                           ` Johannes Thumshirn
2020-05-12 16:24                             ` Martin K. Petersen
     [not found]                 ` <10:12:26>
     [not found]                   ` <-0800")>
2020-12-01  5:19                     ` [PATCH] lpfc: Correct null ndlp reference on routine exit Martin K. Petersen
     [not found]         ` <"Thu>
     [not found]           ` <3>
     [not found]             ` <Dec>
     [not found]               ` <2015>
     [not found]                 ` <07:57:35>
     [not found]                   ` <+0100")>
2015-12-08  1:12                     ` [PATCH] scsi_dh_alua: Remove stale variables Martin K. Petersen
2020-12-09  2:17                     ` [PATCH 0/2] two UFS changes Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201130181226.16675-1-james.smart@broadcom.com \
    --to=james.smart@broadcom.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).