* [PATCH] scsi: lpfc: don't dereference localport before it has been null checked
@ 2017-12-22 0:28 Colin King
2017-12-22 7:20 ` Johannes Thumshirn
2018-01-04 3:53 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2017-12-22 0:28 UTC (permalink / raw)
To: James Smart, Dick Kennedy, James E . J . Bottomley,
Martin K . Petersen, linux-scsi
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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>
---
drivers/scsi/lpfc/lpfc_attr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 797bb42a6306..986a3dc2efaf 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);
--
2.14.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: lpfc: don't dereference localport before it has been null checked
2017-12-22 0:28 [PATCH] scsi: lpfc: don't dereference localport before it has been null checked Colin King
@ 2017-12-22 7:20 ` Johannes Thumshirn
2018-01-04 3:53 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2017-12-22 7:20 UTC (permalink / raw)
To: Colin King
Cc: James Smart, Dick Kennedy, James E . J . Bottomley,
Martin K . Petersen, linux-scsi, kernel-janitors, linux-kernel
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: lpfc: don't dereference localport before it has been null checked
2017-12-22 0:28 [PATCH] scsi: lpfc: don't dereference localport before it has been null checked Colin King
2017-12-22 7:20 ` Johannes Thumshirn
@ 2018-01-04 3:53 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2018-01-04 3:53 UTC (permalink / raw)
To: Colin King
Cc: James Smart, Dick Kennedy, James E . J . Bottomley,
Martin K . Petersen, linux-scsi, kernel-janitors, linux-kernel
Colin,
> 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.
Applied to 4.16/scsi-queue, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-04 3:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-22 0:28 [PATCH] scsi: lpfc: don't dereference localport before it has been null checked Colin King
2017-12-22 7:20 ` Johannes Thumshirn
2018-01-04 3:53 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®