Skip to content

Commit 36b8e18

Browse files
bjking1James Bottomley
authored andcommitted
ipr: Fix locking for unit attention handling
Make sure we have the host lock held when calling scsi_report_bus_reset. Fixes a crash seen as the __devices list in the scsi host was changing as we were iterating through it. Cc: <stable@vger.kernel.org> Reviewed-by: Wen Xiong <wenxiong@linux.vnet.ibm.com> Reviewed-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com> Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Odin.com>
1 parent 1278dd6 commit 36b8e18

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/scsi/ipr.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6263,21 +6263,23 @@ static void ipr_scsi_done(struct ipr_cmnd *ipr_cmd)
62636263
struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
62646264
struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd;
62656265
u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc);
6266-
unsigned long hrrq_flags;
6266+
unsigned long lock_flags;
62676267

62686268
scsi_set_resid(scsi_cmd, be32_to_cpu(ipr_cmd->s.ioasa.hdr.residual_data_len));
62696269

62706270
if (likely(IPR_IOASC_SENSE_KEY(ioasc) == 0)) {
62716271
scsi_dma_unmap(scsi_cmd);
62726272

6273-
spin_lock_irqsave(ipr_cmd->hrrq->lock, hrrq_flags);
6273+
spin_lock_irqsave(ipr_cmd->hrrq->lock, lock_flags);
62746274
list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
62756275
scsi_cmd->scsi_done(scsi_cmd);
6276-
spin_unlock_irqrestore(ipr_cmd->hrrq->lock, hrrq_flags);
6276+
spin_unlock_irqrestore(ipr_cmd->hrrq->lock, lock_flags);
62776277
} else {
6278-
spin_lock_irqsave(ipr_cmd->hrrq->lock, hrrq_flags);
6278+
spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
6279+
spin_lock(&ipr_cmd->hrrq->_lock);
62796280
ipr_erp_start(ioa_cfg, ipr_cmd);
6280-
spin_unlock_irqrestore(ipr_cmd->hrrq->lock, hrrq_flags);
6281+
spin_unlock(&ipr_cmd->hrrq->_lock);
6282+
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
62816283
}
62826284
}
62836285

0 commit comments

Comments
 (0)