Skip to content

Commit 70b25f8

Browse files
htejunJames Bottomley
authored andcommitted
[SCSI] fix locking around blk_abort_request()
blk_abort_request() expects queue lock to be held by the caller. Grab it before calling the function. Lack of this synchronization led to infinite loop on corrupt q->timeout_list. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: stable@kernel.org Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 9a908c1 commit 70b25f8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/scsi/libsas/sas_ata.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,15 @@ int sas_ata_init_host_and_port(struct domain_device *found_dev,
395395
void sas_ata_task_abort(struct sas_task *task)
396396
{
397397
struct ata_queued_cmd *qc = task->uldd_task;
398+
struct request_queue *q = qc->scsicmd->device->request_queue;
398399
struct completion *waiting;
400+
unsigned long flags;
399401

400402
/* Bounce SCSI-initiated commands to the SCSI EH */
401403
if (qc->scsicmd) {
404+
spin_lock_irqsave(q->queue_lock, flags);
402405
blk_abort_request(qc->scsicmd->request);
406+
spin_unlock_irqrestore(q->queue_lock, flags);
403407
scsi_schedule_eh(qc->scsicmd->device->host);
404408
return;
405409
}

drivers/scsi/libsas/sas_scsi_host.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,8 @@ int __sas_task_abort(struct sas_task *task)
10301030
void sas_task_abort(struct sas_task *task)
10311031
{
10321032
struct scsi_cmnd *sc = task->uldd_task;
1033+
struct request_queue *q = sc->device->request_queue;
1034+
unsigned long flags;
10331035

10341036
/* Escape for libsas internal commands */
10351037
if (!sc) {
@@ -1044,7 +1046,9 @@ void sas_task_abort(struct sas_task *task)
10441046
return;
10451047
}
10461048

1049+
spin_lock_irqsave(q->queue_lock, flags);
10471050
blk_abort_request(sc->request);
1051+
spin_unlock_irqrestore(q->queue_lock, flags);
10481052
scsi_schedule_eh(sc->device->host);
10491053
}
10501054

0 commit comments

Comments
 (0)