[SCSI] libsas: SMP request handler shouldn't crash when rphy is NULL

sas_smp_handler crashes when smp utils are used with an aic94xx host
because certain devices (the sas_host itself, specifically) lack rphy
structures.  No rphy means no SMP target support, but we shouldn't crash
here.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
Darrick J. Wong 2007-07-24 09:33:49 -07:00 committed by James Bottomley
parent bbf17d6483
commit 2cd614c873

View File

@ -1879,7 +1879,7 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
struct request *req) struct request *req)
{ {
struct domain_device *dev; struct domain_device *dev;
int ret, type = rphy->identify.device_type; int ret, type;
struct request *rsp = req->next_rq; struct request *rsp = req->next_rq;
if (!rsp) { if (!rsp) {
@ -1888,12 +1888,13 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
return -EINVAL; return -EINVAL;
} }
/* seems aic94xx doesn't support */ /* no rphy means no smp target support (ie aic94xx host) */
if (!rphy) { if (!rphy) {
printk("%s: can we send a smp request to a host?\n", printk("%s: can we send a smp request to a host?\n",
__FUNCTION__); __FUNCTION__);
return -EINVAL; return -EINVAL;
} }
type = rphy->identify.device_type;
if (type != SAS_EDGE_EXPANDER_DEVICE && if (type != SAS_EDGE_EXPANDER_DEVICE &&
type != SAS_FANOUT_EXPANDER_DEVICE) { type != SAS_FANOUT_EXPANDER_DEVICE) {