From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: sathya.prakash@broadcom.com, chaitra.basappa@broadcom.com,
suganath-prabu.subramani@broadcom.com, jejb@linux.ibm.com,
martin.petersen@oracle.com
Cc: MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: [PATCH] scsi: mpt3sas: Fix a possible null-pointer dereference in mpt3sas_transport_update_links()
Date: Mon, 29 Jul 2019 11:08:51 +0800 [thread overview]
Message-ID: <20190729030851.22059-1-baijiaju1990@gmail.com> (raw)
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
reply other threads:[~2019-07-29 3:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190729030851.22059-1-baijiaju1990@gmail.com \
--to=baijiaju1990@gmail.com \
--cc=MPT-FusionLinux.pdl@broadcom.com \
--cc=chaitra.basappa@broadcom.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=sathya.prakash@broadcom.com \
--cc=suganath-prabu.subramani@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).