Commit 50ec5babd3b9da274ac3e0d5ca0c4772e3c7bc8d
Committed by
James Bottomley
1 parent
bdaefbf580
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
[SCSI] pm8001: Fix possible racing condition.
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>
Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff
drivers/scsi/pm8001/pm8001_hwi.c
... | ... | @@ -3869,7 +3869,9 @@ |
3869 | 3869 | void *pMsg1 = NULL; |
3870 | 3870 | u8 bc = 0; |
3871 | 3871 | u32 ret = MPI_IO_STATUS_FAIL; |
3872 | + unsigned long flags; | |
3872 | 3873 | |
3874 | + spin_lock_irqsave(&pm8001_ha->lock, flags); | |
3873 | 3875 | circularQ = &pm8001_ha->outbnd_q_tbl[0]; |
3874 | 3876 | do { |
3875 | 3877 | ret = mpi_msg_consume(pm8001_ha, circularQ, &pMsg1, &bc); |
... | ... | @@ -3890,6 +3892,7 @@ |
3890 | 3892 | break; |
3891 | 3893 | } |
3892 | 3894 | } while (1); |
3895 | + spin_unlock_irqrestore(&pm8001_ha->lock, flags); | |
3893 | 3896 | return ret; |
3894 | 3897 | } |
3895 | 3898 | |
3896 | 3899 | |
... | ... | @@ -4295,12 +4298,9 @@ |
4295 | 4298 | static irqreturn_t |
4296 | 4299 | pm8001_chip_isr(struct pm8001_hba_info *pm8001_ha) |
4297 | 4300 | { |
4298 | - unsigned long flags; | |
4299 | - spin_lock_irqsave(&pm8001_ha->lock, flags); | |
4300 | 4301 | pm8001_chip_interrupt_disable(pm8001_ha); |
4301 | 4302 | process_oq(pm8001_ha); |
4302 | 4303 | pm8001_chip_interrupt_enable(pm8001_ha); |
4303 | - spin_unlock_irqrestore(&pm8001_ha->lock, flags); | |
4304 | 4304 | return IRQ_HANDLED; |
4305 | 4305 | } |
4306 | 4306 |