All of lore.kernel.org
 help / color / mirror / Atom feed
From: Justin Tee <justintee8345@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: jsmart2021@gmail.com, justin.tee@broadcom.com,
	Justin Tee <justintee8345@gmail.com>,
	Dan Carpenter <dan.carpenter@linaro.org>
Subject: [PATCH 3/9] lpfc: Fix list_entry null check warning in lpfc_cmpl_els_plogi
Date: Tue, 31 Oct 2023 12:12:18 -0700	[thread overview]
Message-ID: <20231031191224.150862-4-justintee8345@gmail.com> (raw)
In-Reply-To: <20231031191224.150862-1-justintee8345@gmail.com>

Smatch called out a warning for null checking a ptr that is assigned by
list_entry.  list_entry does not return null and, if the list is empty,
can return an invalid ptr.  Thus, the !psrp check does not execute
properly.

 drivers/scsi/lpfc/lpfc_els.c:2133 lpfc_cmpl_els_plogi()
 warn: list_entry() does not return NULL 'prsp'

Replace list_entry with list_get_first, which does a list_empty check
before returning the first entry.

Fixes: a3c3c0a806f1 ("scsi: lpfc: Validate ELS LS_ACC completion payload")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-scsi/01b7568f-4ab4-4d56-bfa6-9ecc5fc261fe@moroto.mountain/
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_els.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index f9627eddab08..0829fe6ddff8 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -2128,8 +2128,8 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 						NLP_EVT_DEVICE_RM);
 	} else {
 		/* Good status, call state machine */
-		prsp = list_entry(cmdiocb->cmd_dmabuf->list.next,
-				  struct lpfc_dmabuf, list);
+		prsp = list_get_first(&cmdiocb->cmd_dmabuf->list,
+				      struct lpfc_dmabuf, list);
 		if (!prsp)
 			goto out;
 		if (!lpfc_is_els_acc_rsp(prsp))
-- 
2.38.0


  parent reply	other threads:[~2023-10-31 18:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 19:12 [PATCH 0/9] lpfc: Update lpfc to revision 14.2.0.16 Justin Tee
2023-10-31 19:12 ` [PATCH 1/9] lpfc: Correct maximum PCI function value for RAS fw logging Justin Tee
2023-10-31 19:12 ` [PATCH 2/9] lpfc: Fix possible file string name overflow when updating firmware Justin Tee
2023-10-31 19:12 ` Justin Tee [this message]
2023-10-31 19:12 ` [PATCH 4/9] lpfc: Eliminate unnecessary relocking in lpfc_check_nlp_post_devloss Justin Tee
2023-10-31 19:12 ` [PATCH 5/9] lpfc: Return early in lpfc_poll_eratt when the driver is unloading Justin Tee
2023-10-31 19:12 ` [PATCH 6/9] lpfc: Refactor and clean up mailbox command memory free Justin Tee
2023-10-31 19:12 ` [PATCH 7/9] lpfc: Enhance driver logging for selected discovery events Justin Tee
2023-10-31 19:12 ` [PATCH 8/9] lpfc: Update lpfc version to 14.2.0.16 Justin Tee
2023-10-31 19:12 ` [PATCH 9/9] lpfc: Copyright updates for 14.2.0.16 patches Justin Tee
2023-11-02 15:56 ` [PATCH 0/9] lpfc: Update lpfc to revision 14.2.0.16 Himanshu Madhani
2023-11-25  2:54 ` 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=20231031191224.150862-4-justintee8345@gmail.com \
    --to=justintee8345@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=jsmart2021@gmail.com \
    --cc=justin.tee@broadcom.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.