Skip to contentSkip to conversation

scsi: libsas: Fix did not grab the ata port lock in sas_ata_device_link_abort()

PATCH In review Xingui Yang 2 participants 2 messages Dec 21, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: libsas: Fix did not grab the ata port lock in sas_ata_device_link_abort()

Grab the ata port lock in sas_ata_device_link_abort() before calling ata_link_abort(), as the comment in ata_link_abort() mentions.

Fixes 44112922674b ("scsi: libsas: Add sas_ata_device_link_abort()")

---
Changes to v1:
- Add a fixes tag
- Update commit message

---
 drivers/scsi/libsas/sas_ata.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/scsi/libsas/sas_ata.c +3 -0
index f7439bf9cdc6..4f2017b21e6d 100644
@@ -889,7 +889,9 @@ void sas_ata_device_link_abort(struct domain_device *device, bool force_reset)
 {
 	struct ata_port *ap = device->sata_dev.ap;
 	struct ata_link *link = &ap->link;
+	unsigned long flags;
 
+	spin_lock_irqsave(ap->lock, flags);
 	device->sata_dev.fis[2] = ATA_ERR | ATA_DRDY; /* tf status */
 	device->sata_dev.fis[3] = ATA_ABORTED; /* tf error */
 
@@ -897,6 +899,7 @@ void sas_ata_device_link_abort(struct domain_device *device, bool force_reset)
 	if (force_reset)
 		link->eh_info.action |= ATA_EH_RESET;
 	ata_link_abort(link);
+	spin_unlock_irqrestore(ap->lock, flags);
 }
 EXPORT_SYMBOL_GPL(sas_ata_device_link_abort);
 
Signature · 1 line
2.17.1
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Xingui Yang

Grab the ata port lock in sas_ata_device_link_abort() before calling ata_link_abort(), as the comment in ata_link_abort() mentions.

Fixes 44112922674b ("scsi: libsas: Add sas_ata_device_link_abort()")
Quoted 7 lines

---
Changes to v1:
- Add a fixes tag
- Update commit message

---
  drivers/scsi/libsas/sas_ata.c | 3 +++
  1 file changed, 3 insertions(+)

Looks good,