* [PATCH] scsi: mpt3sas: Fix a possible null-pointer dereference in mpt3sas_transport_update_links()
@ 2019-07-29 3:08 Jia-Ju Bai
0 siblings, 0 replies; only message in thread
From: Jia-Ju Bai @ 2019-07-29 3:08 UTC (permalink / raw)
To: sathya.prakash, chaitra.basappa, suganath-prabu.subramani, jejb,
martin.petersen
Cc: MPT-FusionLinux.pdl, linux-scsi, linux-kernel, Jia-Ju Bai
In mpt3sas_transport_update_links(), there is an if statement
on line 994 to check whether mpt3sas_phy->phy is NULL:
if (mpt3sas_phy->phy)
When mpt3sas_phy->phy is NULL, it is used on line 999:
dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev, ...)
Thus, a possible null-pointer dereference may occur.
To fix this bug, mpt3sas_phy->phy is checked before being used.
This bug is found by a static analysis tool STCheck written by us.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
drivers/scsi/mpt3sas/mpt3sas_transport.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c
index 5324662751bf..df790a9877a0 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_transport.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c
@@ -995,7 +995,8 @@ mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc,
mpt3sas_phy->phy->negotiated_linkrate =
_transport_convert_phy_link_rate(link_rate);
- if ((ioc->logging_level & MPT_DEBUG_TRANSPORT))
+ if ((ioc->logging_level & MPT_DEBUG_TRANSPORT) &&
+ mpt3sas_phy->phy)
dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev,
"refresh: parent sas_addr(0x%016llx),\n"
"\tlink_rate(0x%02x), phy(%d)\n"
--
2.17.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-07-29 3:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 3:08 [PATCH] scsi: mpt3sas: Fix a possible null-pointer dereference in mpt3sas_transport_update_links() Jia-Ju Bai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).