aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_attr.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2017-12-22 00:28:52 +0000
committerMartin K. Petersen <martin.petersen@oracle.com>2018-01-03 22:52:43 -0500
commit5c665aeb65aa066775763e59110ba4f5b5917bb6 (patch)
tree095be66c7adf0d3995f8d02bba9547e642156446 /drivers/scsi/lpfc/lpfc_attr.c
parentscsi: scsi_transport_fc: fix typos on 64/128 GBit define names (diff)
downloadlinux-dev-5c665aeb65aa066775763e59110ba4f5b5917bb6.tar.xz
linux-dev-5c665aeb65aa066775763e59110ba4f5b5917bb6.zip
scsi: lpfc: don't dereference localport before it has been null checked
localport is being dereferenced to assign lport and then immediately afterwards localport is being sanity checked to see if it is null. Fix this by only dereferencing localport until after it has been null checked. Detected by CoverityScan, CID#1463038 ("Dereference before null check") Fixes: 3a8cefbfc5ee ("scsi: lpfc: Beef up stat counters for debug") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_attr.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 1bf73262d84d..d188fb565a32 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -277,13 +277,13 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
}
localport = vport->localport;
- lport = (struct lpfc_nvme_lport *)localport->private;
if (!localport) {
len = snprintf(buf, PAGE_SIZE,
"NVME Initiator x%llx is not allocated\n",
wwn_to_u64(vport->fc_portname.u.wwn));
return len;
}
+ lport = (struct lpfc_nvme_lport *)localport->private;
len = snprintf(buf, PAGE_SIZE, "NVME Initiator Enabled\n");
spin_lock_irq(shost->host_lock);