diff mbox series

scsi/ipr: keep the order of locks

Message ID 2DD37C22-98B2-45B9-81F4-4DED4643CDC5@tencent.com
State New
Headers show
Series scsi/ipr: keep the order of locks | expand

Commit Message

flyingpeng(彭浩) Sept. 18, 2022, 2:36 a.m. UTC
ipr_ata_post_internal:
    acquire host_lock
       acquire hrrq->_lock
             ipr_device_reset
                 ipr_send_blocking_cmd
                    release host_lock
                    acquire host_lock
       release hrrq->_lock
    release host_lock

As shown above, there are two lock acquisition order changes.
At the same time, when ipr_device_reset is executed, the lock
hrrq->_lock does not need to be held.

Signed-off-by: Peng Hao <flyingpeng@tencent.com>
---
 drivers/scsi/ipr.c | 2 ++
 1 file changed, 2 insertions(+)

--
2.27.0
diff mbox series

Patch

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 9d01a3e3c26a..6ca987dda397 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -6837,7 +6837,9 @@  static void ipr_ata_post_internal(struct ata_queued_cmd *qc)
                spin_lock(&hrrq->_lock);
                list_for_each_entry(ipr_cmd, &hrrq->hrrq_pending_q, queue) {
                        if (ipr_cmd->qc == qc) {
+                               spin_unlock(&hrrq->_lock);
                                ipr_device_reset(ioa_cfg, sata_port->res);
+                               spin_lock(&hrrq->_lock);
                                break;
                        }
                }