Skip to contentSkip to conversation

scsi: lpfc: prevent potential null pointer dereference

PATCH Applied Gustavo A. R. Silva 3 participants 3 messages May 23, 2017 – Jun 1, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: lpfc: prevent potential null pointer dereference

Null check at line 966: if (ndlp) {, implies that ndlp might be NULL. Functions lpfc_nlp_set_state() and lpfc_issue_els_prli() dereference pointer ndlp. Include these function calls inside the IF block that tests pointer ndlp.

Addresses-Coverity-ID: 1401856

---
 drivers/scsi/lpfc/lpfc_ct.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_ct.c +3 -2
index c7962da..ecb174b 100644
@@ -978,9 +978,10 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 					 ndlp, did, ndlp->nlp_fc4_type,
 					 FC_TYPE_FCP, FC_TYPE_NVME);
 			ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
+
+			lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
+			lpfc_issue_els_prli(vport, ndlp, 0);
 		}
-		lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
-		lpfc_issue_els_prli(vport, ndlp, 0);
 	} else
 		lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
 				 "3065 GFT_ID failed x%08x\n", irsp->ulpStatus);
Signature · 1 line
2.5.0
#1 lore raw

Looks good

-- james

Quoted 7 lines · Gustavo A. R. Silva

Null check at line 966: if (ndlp) {, implies that ndlp might be NULL. Functions lpfc_nlp_set_state() and lpfc_issue_els_prli() dereference pointer ndlp. Include these function calls inside the IF block that tests pointer ndlp.

Addresses-Coverity-ID: 1401856

#2 lore raw
In reply to Gustavo A. R. Silva

Gustavo A.,

Quoted 4 lines

Null check at line 966: if (ndlp) {, implies that ndlp might be NULL. Functions lpfc_nlp_set_state() and lpfc_issue_els_prli() dereference pointer ndlp. Include these function calls inside the IF block that tests pointer ndlp.

Applied to 4.12/scsi-fixes. Thank you!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering