lpfc: Correct null ndlp reference on routine exit
Subsystems (2)
PATCH 1/1 lpfc: Correct null ndlp reference on routine exit
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.
--- drivers/scsi/lpfc/lpfc_els.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_els.c +2 -1
@@ -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;
Signature · 1 line
2.26.2
Martin K. Petersen
AppliedJames,
Quoted 7 lines
smatch correctly called out a logic error with accessing a pointer after checking it for null.
drivers/scsi/lpfc/lpfc_els.c:2043lpfc_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.
Applied to 5.11/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 7 lines · James Smart
smatch correctly called out a logic error with accessing a pointer after checking it for null.
drivers/scsi/lpfc/lpfc_els.c:2043lpfc_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.
Applied to 5.11/scsi-queue, thanks!
[1/1] lpfc: Correct null ndlp reference on routine exit
https://git.kernel.org/mkp/scsi/c/9d8de441db26
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering