Skip to content

Commit 66a8515

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
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 <[email protected]> Signed-off-by: James Smart <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent b15bd3e commit 66a8515

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

drivers/scsi/lpfc/lpfc_nvme.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,18 @@ lpfc_nvme_cmpl_gen_req(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe,
364364
struct lpfc_dmabuf *buf_ptr;
365365
struct lpfc_nodelist *ndlp;
366366

367-
lport = (struct lpfc_nvme_lport *)vport->localport->private;
368367
pnvme_lsreq = (struct nvmefc_ls_req *)cmdwqe->context2;
369368
status = bf_get(lpfc_wcqe_c_status, wcqe) & LPFC_IOCB_STATUS_MASK;
370369

371-
if (lport) {
372-
atomic_inc(&lport->fc4NvmeLsCmpls);
373-
if (status) {
374-
if (bf_get(lpfc_wcqe_c_xb, wcqe))
375-
atomic_inc(&lport->cmpl_ls_xb);
376-
atomic_inc(&lport->cmpl_ls_err);
370+
if (vport->localport) {
371+
lport = (struct lpfc_nvme_lport *)vport->localport->private;
372+
if (lport) {
373+
atomic_inc(&lport->fc4NvmeLsCmpls);
374+
if (status) {
375+
if (bf_get(lpfc_wcqe_c_xb, wcqe))
376+
atomic_inc(&lport->cmpl_ls_xb);
377+
atomic_inc(&lport->cmpl_ls_err);
378+
}
377379
}
378380
}
379381

@@ -980,15 +982,17 @@ lpfc_nvme_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
980982
rport = lpfc_ncmd->nrport;
981983
status = bf_get(lpfc_wcqe_c_status, wcqe);
982984

983-
lport = (struct lpfc_nvme_lport *)vport->localport->private;
984-
if (lport) {
985-
idx = lpfc_ncmd->cur_iocbq.hba_wqidx;
986-
cstat = &lport->cstat[idx];
987-
atomic_inc(&cstat->fc4NvmeIoCmpls);
988-
if (status) {
989-
if (bf_get(lpfc_wcqe_c_xb, wcqe))
990-
atomic_inc(&lport->cmpl_fcp_xb);
991-
atomic_inc(&lport->cmpl_fcp_err);
985+
if (vport->localport) {
986+
lport = (struct lpfc_nvme_lport *)vport->localport->private;
987+
if (lport) {
988+
idx = lpfc_ncmd->cur_iocbq.hba_wqidx;
989+
cstat = &lport->cstat[idx];
990+
atomic_inc(&cstat->fc4NvmeIoCmpls);
991+
if (status) {
992+
if (bf_get(lpfc_wcqe_c_xb, wcqe))
993+
atomic_inc(&lport->cmpl_fcp_xb);
994+
atomic_inc(&lport->cmpl_fcp_err);
995+
}
992996
}
993997
}
994998

0 commit comments

Comments
 (0)