diff options
author | Tejun Heo <htejun@gmail.com> | 2006-11-21 21:21:31 -0500 |
---|---|---|
committer | Tejun Heo <htejun@gmail.com> | 2006-12-03 03:56:24 -0500 |
commit | f84e7e41e1b88547218a3c3b1eb528005e9afdb4 (patch) | |
tree | 60142d47e5293405701ac44d97722762c7386beb /drivers/ata/libata-scsi.c | |
parent | a569a30d301e4dbc0ad67a211292edece2da1146 (diff) |
[PATCH] libata: make sure sdev doesn't go away while rescanning
ata_scsi_dev_rescan() doesn't synchronize against SCSI device detach
and the target sdev might go away in the middle. Fix it.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'drivers/ata/libata-scsi.c')
-rw-r--r-- | drivers/ata/libata-scsi.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 7ff1adfc729c..d250858d201c 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -3181,15 +3181,27 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel, | |||
3181 | void ata_scsi_dev_rescan(void *data) | 3181 | void ata_scsi_dev_rescan(void *data) |
3182 | { | 3182 | { |
3183 | struct ata_port *ap = data; | 3183 | struct ata_port *ap = data; |
3184 | struct ata_device *dev; | 3184 | unsigned long flags; |
3185 | unsigned int i; | 3185 | unsigned int i; |
3186 | 3186 | ||
3187 | spin_lock_irqsave(ap->lock, flags); | ||
3188 | |||
3187 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 3189 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
3188 | dev = &ap->device[i]; | 3190 | struct ata_device *dev = &ap->device[i]; |
3191 | struct scsi_device *sdev = dev->sdev; | ||
3189 | 3192 | ||
3190 | if (ata_dev_enabled(dev) && dev->sdev) | 3193 | if (!ata_dev_enabled(dev) || !sdev) |
3191 | scsi_rescan_device(&(dev->sdev->sdev_gendev)); | 3194 | continue; |
3195 | if (scsi_device_get(sdev)) | ||
3196 | continue; | ||
3197 | |||
3198 | spin_unlock_irqrestore(ap->lock, flags); | ||
3199 | scsi_rescan_device(&(sdev->sdev_gendev)); | ||
3200 | scsi_device_put(sdev); | ||
3201 | spin_lock_irqsave(ap->lock, flags); | ||
3192 | } | 3202 | } |
3203 | |||
3204 | spin_unlock_irqrestore(ap->lock, flags); | ||
3193 | } | 3205 | } |
3194 | 3206 | ||
3195 | /** | 3207 | /** |