aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion
diff options
context:
space:
mode:
authorKashyap, Desai <kashyap.desai@lsi.com>2010-03-18 09:52:45 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-04-11 10:24:10 -0400
commit08f5c5c23d52aa385ff304becffb0e0c37cedfe5 (patch)
tree5e6b65987b69ee4c240b413fc682b37935bd13e5 /drivers/message/fusion
parentf8c23bde85091b696e72d00bc6aa16216a9862f7 (diff)
[SCSI] mptfusion: sanity check for vdevice pointer is added
Added sanity checks before accessing vdevice and added vdevice->deleted setting for mptfc. Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/message/fusion')
-rw-r--r--drivers/message/fusion/mptctl.c7
-rw-r--r--drivers/message/fusion/mptfc.c17
-rw-r--r--drivers/message/fusion/mptscsih.c2
3 files changed, 26 insertions, 0 deletions
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index e7fab5de16e7..f06b29193b4e 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -1329,6 +1329,8 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
1329 if (ioc->sh) { 1329 if (ioc->sh) {
1330 shost_for_each_device(sdev, ioc->sh) { 1330 shost_for_each_device(sdev, ioc->sh) {
1331 vdevice = sdev->hostdata; 1331 vdevice = sdev->hostdata;
1332 if (vdevice == NULL || vdevice->vtarget == NULL)
1333 continue;
1332 if (vdevice->vtarget->tflags & 1334 if (vdevice->vtarget->tflags &
1333 MPT_TARGET_FLAGS_RAID_COMPONENT) 1335 MPT_TARGET_FLAGS_RAID_COMPONENT)
1334 continue; 1336 continue;
@@ -1450,6 +1452,8 @@ mptctl_gettargetinfo (unsigned long arg)
1450 if (!maxWordsLeft) 1452 if (!maxWordsLeft)
1451 continue; 1453 continue;
1452 vdevice = sdev->hostdata; 1454 vdevice = sdev->hostdata;
1455 if (vdevice == NULL || vdevice->vtarget == NULL)
1456 continue;
1453 if (vdevice->vtarget->tflags & 1457 if (vdevice->vtarget->tflags &
1454 MPT_TARGET_FLAGS_RAID_COMPONENT) 1458 MPT_TARGET_FLAGS_RAID_COMPONENT)
1455 continue; 1459 continue;
@@ -1978,6 +1982,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
1978 struct scsi_target *starget = scsi_target(sdev); 1982 struct scsi_target *starget = scsi_target(sdev);
1979 VirtTarget *vtarget = starget->hostdata; 1983 VirtTarget *vtarget = starget->hostdata;
1980 1984
1985 if (vtarget == NULL)
1986 continue;
1987
1981 if ((pScsiReq->TargetID == vtarget->id) && 1988 if ((pScsiReq->TargetID == vtarget->id) &&
1982 (pScsiReq->Bus == vtarget->channel) && 1989 (pScsiReq->Bus == vtarget->channel) &&
1983 (vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) 1990 (vtarget->tflags & MPT_TARGET_FLAGS_Q_YES))
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 8b3ff2d43fb3..b5f03ad81568 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -482,6 +482,7 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0)
482 if (vtarget) { 482 if (vtarget) {
483 vtarget->id = pg0->CurrentTargetID; 483 vtarget->id = pg0->CurrentTargetID;
484 vtarget->channel = pg0->CurrentBus; 484 vtarget->channel = pg0->CurrentBus;
485 vtarget->deleted = 0;
485 } 486 }
486 } 487 }
487 *((struct mptfc_rport_info **)rport->dd_data) = ri; 488 *((struct mptfc_rport_info **)rport->dd_data) = ri;
@@ -1092,6 +1093,8 @@ mptfc_setup_reset(struct work_struct *work)
1092 container_of(work, MPT_ADAPTER, fc_setup_reset_work); 1093 container_of(work, MPT_ADAPTER, fc_setup_reset_work);
1093 u64 pn; 1094 u64 pn;
1094 struct mptfc_rport_info *ri; 1095 struct mptfc_rport_info *ri;
1096 struct scsi_target *starget;
1097 VirtTarget *vtarget;
1095 1098
1096 /* reset about to happen, delete (block) all rports */ 1099 /* reset about to happen, delete (block) all rports */
1097 list_for_each_entry(ri, &ioc->fc_rports, list) { 1100 list_for_each_entry(ri, &ioc->fc_rports, list) {
@@ -1099,6 +1102,12 @@ mptfc_setup_reset(struct work_struct *work)
1099 ri->flags &= ~MPT_RPORT_INFO_FLAGS_REGISTERED; 1102 ri->flags &= ~MPT_RPORT_INFO_FLAGS_REGISTERED;
1100 fc_remote_port_delete(ri->rport); /* won't sleep */ 1103 fc_remote_port_delete(ri->rport); /* won't sleep */
1101 ri->rport = NULL; 1104 ri->rport = NULL;
1105 starget = ri->starget;
1106 if (starget) {
1107 vtarget = starget->hostdata;
1108 if (vtarget)
1109 vtarget->deleted = 1;
1110 }
1102 1111
1103 pn = (u64)ri->pg0.WWPN.High << 32 | 1112 pn = (u64)ri->pg0.WWPN.High << 32 |
1104 (u64)ri->pg0.WWPN.Low; 1113 (u64)ri->pg0.WWPN.Low;
@@ -1119,6 +1128,8 @@ mptfc_rescan_devices(struct work_struct *work)
1119 int ii; 1128 int ii;
1120 u64 pn; 1129 u64 pn;
1121 struct mptfc_rport_info *ri; 1130 struct mptfc_rport_info *ri;
1131 struct scsi_target *starget;
1132 VirtTarget *vtarget;
1122 1133
1123 /* start by tagging all ports as missing */ 1134 /* start by tagging all ports as missing */
1124 list_for_each_entry(ri, &ioc->fc_rports, list) { 1135 list_for_each_entry(ri, &ioc->fc_rports, list) {
@@ -1146,6 +1157,12 @@ mptfc_rescan_devices(struct work_struct *work)
1146 MPT_RPORT_INFO_FLAGS_MISSING); 1157 MPT_RPORT_INFO_FLAGS_MISSING);
1147 fc_remote_port_delete(ri->rport); /* won't sleep */ 1158 fc_remote_port_delete(ri->rport); /* won't sleep */
1148 ri->rport = NULL; 1159 ri->rport = NULL;
1160 starget = ri->starget;
1161 if (starget) {
1162 vtarget = starget->hostdata;
1163 if (vtarget)
1164 vtarget->deleted = 1;
1165 }
1149 1166
1150 pn = (u64)ri->pg0.WWPN.High << 32 | 1167 pn = (u64)ri->pg0.WWPN.High << 32 |
1151 (u64)ri->pg0.WWPN.Low; 1168 (u64)ri->pg0.WWPN.Low;
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index b966678e4419..90a1dff7eb84 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -2339,6 +2339,8 @@ mptscsih_slave_destroy(struct scsi_device *sdev)
2339 starget = scsi_target(sdev); 2339 starget = scsi_target(sdev);
2340 vtarget = starget->hostdata; 2340 vtarget = starget->hostdata;
2341 vdevice = sdev->hostdata; 2341 vdevice = sdev->hostdata;
2342 if (!vdevice)
2343 return;
2342 2344
2343 mptscsih_search_running_cmds(hd, vdevice); 2345 mptscsih_search_running_cmds(hd, vdevice);
2344 vtarget->num_luns--; 2346 vtarget->num_luns--;