Skip to content

Commit a169515

Browse files
committed
ata: libata-scsi: Improve ata_scsi_handle_link_detach()
A struct ata_device flags should always be set and cleared with the device port locked. Testing for a flag should thus also be done while holding the device port lock. In accordance to this principle, modify ata_scsi_handle_link_detach() to test and clear the ATA_DFLAG_DETACHED flag while holding the device port lock. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Niklas Cassel <[email protected]>
1 parent c494708 commit a169515

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/ata/libata-scsi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4605,10 +4605,12 @@ static void ata_scsi_handle_link_detach(struct ata_link *link)
46054605
ata_for_each_dev(dev, link, ALL) {
46064606
unsigned long flags;
46074607

4608-
if (!(dev->flags & ATA_DFLAG_DETACHED))
4608+
spin_lock_irqsave(ap->lock, flags);
4609+
if (!(dev->flags & ATA_DFLAG_DETACHED)) {
4610+
spin_unlock_irqrestore(ap->lock, flags);
46094611
continue;
4612+
}
46104613

4611-
spin_lock_irqsave(ap->lock, flags);
46124614
dev->flags &= ~ATA_DFLAG_DETACHED;
46134615
spin_unlock_irqrestore(ap->lock, flags);
46144616

0 commit comments

Comments
 (0)