Skip to content

Commit

Permalink
[SCSI] pm8001: Fix possible racing condition.
Browse files Browse the repository at this point in the history
There is a possble racing scenario.

'process_oq' is called by two routines, as shown below.

pm8001_8001_dispatch = {
         .......

        .isr             = pm8001_chip_isr --> process_oq,// A
        .isr_process_oq  = process_oq,                   //  B
        .....
}

process_oq() --> process_one_iomb() --> mpi_sata_completion()

In 'mpi_sata_completion', "pm8001_ha->lock" is first released.
It means lock is taken before,  which is true for
the context A, as 'pm8001_ha->lock' is taken in 'pm8001_chip_isr()'

But for context B there is no lock taken before and pm8001_ha->lock
is unlocked in 'mpi_sata_completion()'. This may unlock the lock
taken in context A. Possible racing ??

If 'pm8001_ha->lock' is taken in 'process_oq()' instead of
'pm8001_chip_isr' then the above issue can be avoided.

Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
Acked-by: Jack Wang <jack_wang@usish.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
  • Loading branch information
Santosh Nayak authored and James Bottomley committed Feb 29, 2012
1 parent bdaefbf commit 50ec5ba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/scsi/pm8001/pm8001_hwi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3869,7 +3869,9 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha)
void *pMsg1 = NULL;
u8 bc = 0;
u32 ret = MPI_IO_STATUS_FAIL;
unsigned long flags;

spin_lock_irqsave(&pm8001_ha->lock, flags);
circularQ = &pm8001_ha->outbnd_q_tbl[0];
do {
ret = mpi_msg_consume(pm8001_ha, circularQ, &pMsg1, &bc);
Expand All @@ -3890,6 +3892,7 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha)
break;
}
} while (1);
spin_unlock_irqrestore(&pm8001_ha->lock, flags);
return ret;
}

Expand Down Expand Up @@ -4295,12 +4298,9 @@ static u32 pm8001_chip_is_our_interupt(struct pm8001_hba_info *pm8001_ha)
static irqreturn_t
pm8001_chip_isr(struct pm8001_hba_info *pm8001_ha)
{
unsigned long flags;
spin_lock_irqsave(&pm8001_ha->lock, flags);
pm8001_chip_interrupt_disable(pm8001_ha);
process_oq(pm8001_ha);
pm8001_chip_interrupt_enable(pm8001_ha);
spin_unlock_irqrestore(&pm8001_ha->lock, flags);
return IRQ_HANDLED;
}

Expand Down

0 comments on commit 50ec5ba

Please sign in to comment.