scsi: lpfc: Fix NULL pointer reference when resetting adapter

Points referencing local port structures didn't accommodate cases where
the localport may not be registered yet.

Add NULL pointer checks to logic.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
James Smart 2018-04-09 14:24:31 -07:00 коммит произвёл Martin K. Petersen
Родитель b15bd3e621
Коммит 66a85155d4
1 изменённых файлов: 20 добавлений и 16 удалений

Просмотреть файл

@ -364,16 +364,18 @@ lpfc_nvme_cmpl_gen_req(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe,
struct lpfc_dmabuf *buf_ptr; struct lpfc_dmabuf *buf_ptr;
struct lpfc_nodelist *ndlp; struct lpfc_nodelist *ndlp;
lport = (struct lpfc_nvme_lport *)vport->localport->private;
pnvme_lsreq = (struct nvmefc_ls_req *)cmdwqe->context2; pnvme_lsreq = (struct nvmefc_ls_req *)cmdwqe->context2;
status = bf_get(lpfc_wcqe_c_status, wcqe) & LPFC_IOCB_STATUS_MASK; status = bf_get(lpfc_wcqe_c_status, wcqe) & LPFC_IOCB_STATUS_MASK;
if (lport) { if (vport->localport) {
atomic_inc(&lport->fc4NvmeLsCmpls); lport = (struct lpfc_nvme_lport *)vport->localport->private;
if (status) { if (lport) {
if (bf_get(lpfc_wcqe_c_xb, wcqe)) atomic_inc(&lport->fc4NvmeLsCmpls);
atomic_inc(&lport->cmpl_ls_xb); if (status) {
atomic_inc(&lport->cmpl_ls_err); if (bf_get(lpfc_wcqe_c_xb, wcqe))
atomic_inc(&lport->cmpl_ls_xb);
atomic_inc(&lport->cmpl_ls_err);
}
} }
} }
@ -980,15 +982,17 @@ lpfc_nvme_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
rport = lpfc_ncmd->nrport; rport = lpfc_ncmd->nrport;
status = bf_get(lpfc_wcqe_c_status, wcqe); status = bf_get(lpfc_wcqe_c_status, wcqe);
lport = (struct lpfc_nvme_lport *)vport->localport->private; if (vport->localport) {
if (lport) { lport = (struct lpfc_nvme_lport *)vport->localport->private;
idx = lpfc_ncmd->cur_iocbq.hba_wqidx; if (lport) {
cstat = &lport->cstat[idx]; idx = lpfc_ncmd->cur_iocbq.hba_wqidx;
atomic_inc(&cstat->fc4NvmeIoCmpls); cstat = &lport->cstat[idx];
if (status) { atomic_inc(&cstat->fc4NvmeIoCmpls);
if (bf_get(lpfc_wcqe_c_xb, wcqe)) if (status) {
atomic_inc(&lport->cmpl_fcp_xb); if (bf_get(lpfc_wcqe_c_xb, wcqe))
atomic_inc(&lport->cmpl_fcp_err); atomic_inc(&lport->cmpl_fcp_xb);
atomic_inc(&lport->cmpl_fcp_err);
}
} }
} }