summaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorDamien Le Moal <dlemoal@kernel.org>2024-09-05 11:00:59 +0900
committerDamien Le Moal <dlemoal@kernel.org>2024-09-07 10:16:55 +0900
commita16951510fae8fa9b934673404c4fc990d124ccd (patch)
tree863e2ee6c3d188d71e16c79dc787c3c4dac3aed3 /drivers/ata
parentc494708d1f680027c7cbbaa670198179774f7d4d (diff)
downloadlinux-stable-a16951510fae8fa9b934673404c4fc990d124ccd.tar.gz
linux-stable-a16951510fae8fa9b934673404c4fc990d124ccd.tar.bz2
linux-stable-a16951510fae8fa9b934673404c4fc990d124ccd.zip
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 <dlemoal@kernel.org> Reviewed-by: Niklas Cassel <cassel@kernel.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-scsi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 3a442f564b0d..6bd7ab27fcbb 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -4605,10 +4605,12 @@ static void ata_scsi_handle_link_detach(struct ata_link *link)
ata_for_each_dev(dev, link, ALL) {
unsigned long flags;
- if (!(dev->flags & ATA_DFLAG_DETACHED))
+ spin_lock_irqsave(ap->lock, flags);
+ if (!(dev->flags & ATA_DFLAG_DETACHED)) {
+ spin_unlock_irqrestore(ap->lock, flags);
continue;
+ }
- spin_lock_irqsave(ap->lock, flags);
dev->flags &= ~ATA_DFLAG_DETACHED;
spin_unlock_irqrestore(ap->lock, flags);