scsi: lpfc: prevent potential null pointer dereference
authorGustavo A. R. Silva <garsilva@embeddedor.com>
Tue, 23 May 2017 15:09:28 +0000 (10:09 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 1 Jun 2017 02:45:15 +0000 (22:45 -0400)
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
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_ct.c

index f2cd19c6c2df9fd77516d18fddf2de04cf531437..24ce96dcc94d4ce0fffd8109e89a80193b71bb16 100644 (file)
@@ -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);