linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi_transport_sas: Potential NULL pointer deference in sas_rphy_match()
@ 2019-10-07 20:22 Yizhuo
  0 siblings, 0 replies; only message in thread
From: Yizhuo @ 2019-10-07 20:22 UTC (permalink / raw)
  Cc: Yizhuo, James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel

Inside function sas_rphy_match(), dev_to_shost() could return NULL,
however, the return value of dev_to_shost() is not checked and
get used. This could potentially be unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/scsi/scsi_transport_sas.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index ef138c57e2a6..04d83cbc35f2 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -1328,6 +1328,8 @@ static int sas_rphy_match(struct attribute_container *cont, struct device *dev)
 	if (!scsi_is_sas_rphy(dev))
 		return 0;
 	shost = dev_to_shost(dev->parent->parent);
+	if (!shost)
+		return 0;
 
 	if (!shost->transportt)
 		return 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-10-07 20:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 20:22 [PATCH] scsi_transport_sas: Potential NULL pointer deference in sas_rphy_match() Yizhuo

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).