[SCSI] fc_transport: Check portstates before invoking target scan
authorHannes Reinecke <hare@suse.de>
Thu, 14 Jun 2007 13:16:45 +0000 (15:16 +0200)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Sun, 17 Jun 2007 21:03:11 +0000 (16:03 -0500)
When a target scan is initiated from sysfs, we should check the
portstate prior to invoke scsi_scan_target().
Otherwise scsi_scan_target() might oops as the rport might already
been removed from the scsi host and the traversal from the rport to
the scsi_host in scsi_scan_target() will fail.
Also the portstate already told us that communication with the target
has failed, so it's quite pointless to try.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Cc: James Smart <James.Smart@Emulex.Com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/scsi_transport_fc.c

index 4953f0dca02980c3f59a1a516d5dde4a0ac2c206..e8825709797eee5b8a972cd40d7a080772705180 100644 (file)
@@ -1943,6 +1943,9 @@ static int fc_user_scan(struct Scsi_Host *shost, uint channel,
                if (rport->scsi_target_id == -1)
                        continue;
 
+               if (rport->port_state != FC_PORTSTATE_ONLINE)
+                       continue;
+
                if ((channel == SCAN_WILD_CARD || channel == rport->channel) &&
                    (id == SCAN_WILD_CARD || id == rport->scsi_target_id)) {
                        scsi_scan_target(&rport->dev, rport->channel,