Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] fc_transport: Check portstates before invoking target scan

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>

authored by

Hannes Reinecke and committed by
James Bottomley
0d2fcd9f 1c138991

+3
+3
drivers/scsi/scsi_transport_fc.c
··· 1943 1943 if (rport->scsi_target_id == -1) 1944 1944 continue; 1945 1945 1946 + if (rport->port_state != FC_PORTSTATE_ONLINE) 1947 + continue; 1948 + 1946 1949 if ((channel == SCAN_WILD_CARD || channel == rport->channel) && 1947 1950 (id == SCAN_WILD_CARD || id == rport->scsi_target_id)) { 1948 1951 scsi_scan_target(&rport->dev, rport->channel,