Skip to content

Commit 1dec131

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Fix list_entry null check warning in lpfc_cmpl_els_plogi()
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: a3c3c0a ("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> Link: https://lore.kernel.org/r/20231031191224.150862-4-justintee8345@gmail.com Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent f5779b5 commit 1dec131

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/scsi/lpfc/lpfc_els.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,8 +2128,8 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
21282128
NLP_EVT_DEVICE_RM);
21292129
} else {
21302130
/* Good status, call state machine */
2131-
prsp = list_entry(cmdiocb->cmd_dmabuf->list.next,
2132-
struct lpfc_dmabuf, list);
2131+
prsp = list_get_first(&cmdiocb->cmd_dmabuf->list,
2132+
struct lpfc_dmabuf, list);
21332133
if (!prsp)
21342134
goto out;
21352135
if (!lpfc_is_els_acc_rsp(prsp))

0 commit comments

Comments
 (0)