scsi: qla2xxx: Fix unbound sleep in fcport delete path.
authorQuinn Tran <qutran@marvell.com>
Thu, 12 Sep 2019 18:09:06 +0000 (11:09 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Oct 2019 08:14:58 +0000 (09:14 +0100)
[ Upstream commit c3b6a1d397420a0fdd97af2f06abfb78adc370df ]

There are instances, though rare, where a LOGO request cannot be sent out
and the thread in free session done can wait indefinitely. Fix this by
putting an upper bound to sleep.

Link: https://lore.kernel.org/r/20190912180918.6436-3-hmadhani@marvell.com
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/qla2xxx/qla_target.c

index 11f45cb998927b1fe655c382b0a160d8a57fd32a..d13e91e164258ccce111edd643dd57526c88a0f4 100644 (file)
@@ -572,6 +572,7 @@ static void qlt_free_session_done(struct work_struct *work)
 
        if (logout_started) {
                bool traced = false;
+               u16 cnt = 0;
 
                while (!ACCESS_ONCE(sess->logout_completed)) {
                        if (!traced) {
@@ -581,6 +582,9 @@ static void qlt_free_session_done(struct work_struct *work)
                                traced = true;
                        }
                        msleep(100);
+                       cnt++;
+                       if (cnt > 200)
+                               break;
                }
 
                ql_dbg(ql_dbg_tgt_mgt, vha, 0xf087,