Skip to content

Commit

Permalink
[SCSI] libsas: fix deref before check in commit 70b25f8
Browse files Browse the repository at this point in the history
commit 70b25f8
Author: Tejun Heo <tj@kernel.org>
Date:   Thu Apr 15 09:00:08 2010 +0900

    [SCSI] fix locking around blk_abort_request()

Introduced a reference before check problem, fix this by moving the
lock shorthand code to be right at the point of actual use.

Reported-by: Dan Carpenter <error27@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
James Bottomley authored and James Bottomley committed May 16, 2010
1 parent b5dbc85 commit 1b4d0d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions drivers/scsi/libsas/sas_ata.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,13 @@ int sas_ata_init_host_and_port(struct domain_device *found_dev,
void sas_ata_task_abort(struct sas_task *task)
{
struct ata_queued_cmd *qc = task->uldd_task;
struct request_queue *q = qc->scsicmd->device->request_queue;
struct completion *waiting;
unsigned long flags;

/* Bounce SCSI-initiated commands to the SCSI EH */
if (qc->scsicmd) {
struct request_queue *q = qc->scsicmd->device->request_queue;
unsigned long flags;

spin_lock_irqsave(q->queue_lock, flags);
blk_abort_request(qc->scsicmd->request);
spin_unlock_irqrestore(q->queue_lock, flags);
Expand Down
16 changes: 8 additions & 8 deletions drivers/scsi/libsas/sas_scsi_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,6 @@ int __sas_task_abort(struct sas_task *task)
void sas_task_abort(struct sas_task *task)
{
struct scsi_cmnd *sc = task->uldd_task;
struct request_queue *q = sc->device->request_queue;
unsigned long flags;

/* Escape for libsas internal commands */
if (!sc) {
Expand All @@ -1043,13 +1041,15 @@ void sas_task_abort(struct sas_task *task)

if (dev_is_sata(task->dev)) {
sas_ata_task_abort(task);
return;
}
} else {
struct request_queue *q = sc->device->request_queue;
unsigned long flags;

spin_lock_irqsave(q->queue_lock, flags);
blk_abort_request(sc->request);
spin_unlock_irqrestore(q->queue_lock, flags);
scsi_schedule_eh(sc->device->host);
spin_lock_irqsave(q->queue_lock, flags);
blk_abort_request(sc->request);
spin_unlock_irqrestore(q->queue_lock, flags);
scsi_schedule_eh(sc->device->host);
}
}

int sas_slave_alloc(struct scsi_device *scsi_dev)
Expand Down

0 comments on commit 1b4d0d8

Please sign in to comment.