aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/scsi_sysfs.c')
-rw-r--r--drivers/scsi/scsi_sysfs.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 83f87c41b18d..1e47b7eddef4 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -719,17 +719,20 @@ void __scsi_remove_target(struct scsi_target *starget)
719{ 719{
720 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 720 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
721 unsigned long flags; 721 unsigned long flags;
722 struct scsi_device *sdev, *tmp; 722 struct scsi_device *sdev;
723 723
724 spin_lock_irqsave(shost->host_lock, flags); 724 spin_lock_irqsave(shost->host_lock, flags);
725 starget->reap_ref++; 725 starget->reap_ref++;
726 list_for_each_entry_safe(sdev, tmp, &shost->__devices, siblings) { 726 restart:
727 list_for_each_entry(sdev, &shost->__devices, siblings) {
727 if (sdev->channel != starget->channel || 728 if (sdev->channel != starget->channel ||
728 sdev->id != starget->id) 729 sdev->id != starget->id ||
730 sdev->sdev_state == SDEV_DEL)
729 continue; 731 continue;
730 spin_unlock_irqrestore(shost->host_lock, flags); 732 spin_unlock_irqrestore(shost->host_lock, flags);
731 scsi_remove_device(sdev); 733 scsi_remove_device(sdev);
732 spin_lock_irqsave(shost->host_lock, flags); 734 spin_lock_irqsave(shost->host_lock, flags);
735 goto restart;
733 } 736 }
734 spin_unlock_irqrestore(shost->host_lock, flags); 737 spin_unlock_irqrestore(shost->host_lock, flags);
735 scsi_target_reap(starget); 738 scsi_target_reap(starget);