From patchwork Wed Mar 15 16:48:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 9626171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C1CDD60244 for ; Wed, 15 Mar 2017 16:50:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B450628641 for ; Wed, 15 Mar 2017 16:50:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A937728669; Wed, 15 Mar 2017 16:50:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0146E2866C for ; Wed, 15 Mar 2017 16:50:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752569AbdCOQun (ORCPT ); Wed, 15 Mar 2017 12:50:43 -0400 Received: from mail-by2nam01on0074.outbound.protection.outlook.com ([104.47.34.74]:47712 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752964AbdCOQtP (ORCPT ); Wed, 15 Mar 2017 12:49:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=S70d2EQKMJickDrkTg8W+3pKy/9QZh1n1soE4br6J0I=; b=YUJctFuq/+JngiVyhrHIDQv05YUF4cBgaanhOlBi9BuPIhiPg9WlzmT0Iz7JKXbKWePBZfwrz88SIiPGAJ39SxZMNAeRZVBsvHN43wNmk15RGhCL4EYx7adJ5i6w05OIdHo8nNcoNzrcr+aE3VQtL2SdnBWcWyelaMdfiXnzeis= Received: from BLUPR07CA091.namprd07.prod.outlook.com (10.160.24.46) by DM2PR07MB480.namprd07.prod.outlook.com (10.141.159.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Wed, 15 Mar 2017 16:49:14 +0000 Received: from BL2FFO11FD017.protection.gbl (2a01:111:f400:7c09::121) by BLUPR07CA091.outlook.office365.com (2a01:111:e400:8ae::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11 via Frontend Transport; Wed, 15 Mar 2017 16:49:13 +0000 Authentication-Results: spf=none (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; linux-iscsi.org; dkim=none (message not signed) header.d=none; linux-iscsi.org; dmarc=none action=none header.from=cavium.com; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BL2FFO11FD017.mail.protection.outlook.com (10.173.161.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.961.10 via Frontend Transport; Wed, 15 Mar 2017 16:49:13 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.309.2; Wed, 15 Mar 2017 09:48:57 -0700 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id v2FGmveg017310; Wed, 15 Mar 2017 09:48:57 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v2FGmvYI017309; Wed, 15 Mar 2017 09:48:57 -0700 From: Himanshu Madhani To: , , CC: , , Subject: [PATCH v4 05/14] qla2xxx: Fix sess_lock & hardware_lock lock order problem. Date: Wed, 15 Mar 2017 09:48:47 -0700 Message-ID: <20170315164856.17255-6-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170315164856.17255-1-himanshu.madhani@cavium.com> References: <20170315164856.17255-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(39410400002)(39450400003)(2980300002)(428002)(199003)(189002)(9170700003)(107886003)(33646002)(38730400002)(8936002)(305945005)(81166006)(47776003)(4326008)(50226002)(50986999)(42186005)(356003)(36756003)(101416001)(76176999)(105586002)(2906002)(5003940100001)(2201001)(54906002)(8656002)(50466002)(48376002)(6666003)(5660300001)(8676002)(189998001)(1076002)(86362001)(2950100002)(80596001)(87636001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR07MB480; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD017; 1:lJFtCnHuPRI0FR6z8ZZILfiRwtoDRvGL1uZHYBAse2WwWX3rE98Rwav0GHGeiGanUIObyyFvtUhkoLSGhqLpyHKB+Wo9mrxzgkS69A5JqSUDl+fQ7esvoWcHDeE8gqaHg8wBvp9mOyiP/D9iBU7MxujMDbVhNyxWeJkwOhfsSSk6l+dTUjId2UUEX2qB7rnb1kZJgzpnYkdjpJvoz1S75r3JpXVCJHP7Mm6qJ+/a4tC9Uvym9ds95rg5WiykR2e0v4AjAnJYkWFLzidr2BcjY7+eQsc/4XEJurQuLLeb7CclmG3/kxOZlL6UCBa2KA5VMxpIhaLPexGCSVlSATl8Jn9NyD7f3vAGuCq3nJtcOIHTh2hrHg/4pXGJIPfYrixbqhmlIm3D7SVMJ+ZUnYlqLyNDwkoBSnuW5hwrkxr1dEGBE1U4CkWhnEwNkNJ4Yt3w7q6ojVP8s2wVw2T2ELkC4F2BL+D7xcn8eZY2tyaJJk/49Q7cIjgur7sBfNLhTcm4PJPKpuiMAKKKOZRpyAc0n0MjoYp7ra9XdNG3lSCP6gs= X-MS-Office365-Filtering-Correlation-Id: e99acdcc-b320-4651-8df2-08d46bc335ee X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DM2PR07MB480; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB480; 3:HvxBAzkJTkxQRowRD0wnPE5zJ+yJQ6PRZUzLGS2JFF2t90MwrzWxqK2+w32RnxFgxmXSiXrdNCk3SCD9zYrMKGApnxUcsFNhLuEsBrcV1nYWtAt+9tH4YKNLdo4nGgEoNkOegs5ubufHYv065IJTWNk0EZj7d1i+uph3vN3WsM5RsxOfP8gzQ7JLEv3RgNLUKz8wbbi1k76dH7+IenEz1MvlaM9VeSDS7ZC9d8RcWZtVxN8hUGuI0rCN9vost6byN/Vf8FV07SIC4RPMD+SZGVnX/mhD6zgy9MbTp5UlF0Nh7uY8QxMOjUm6OQlDoayr8kSmRyOnY/S66JDZ+sE+HNZ0P6+Tk1QUf1iskny2n9bK33H2VCrt8LyVVZnUjK7r; 25:0jPWytm9AeMg60+84b51csdeXz80wQdh6OBh1/riqqncF7Clc54B8AfxMYNimFpLlWy5dPdwJotXSknO151AOtOYRjv9xJkprM9yrd4ybKLWZe+EAXalk4/RPU7w2lltWGOA6Da5haWZnhph+fAEGhnkeHJFuck9eatk0YN481ql705ICPj25DeAcGsmm127gT5D23Wk+XCqpmGvNtptlOX9sPPys4ULmp3pip8RZuox2J3CMBrcbQkD1amwzWo75ITuG6hgI3+g7qDV59TqQ05ReosOQoGBxlaPOsnBYa7DJjH4A4XhXKhVoZ7AmmEh389uc4wMIhbSpoHsV0WufNG0r0hkhht3UK2Ula4Py2S4BAe1C9sfAzHs/eFQ+rHgVuUxUmccK06I/8YYRGaSLQSpfwwz7G/kMfGrH0A3jznYwEoP406UkFP14O4rMv8Ntwr/93jaE967UwcPBSGSWg== X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB480; 31:nS080gFpRSd1/0fODGWmiU+2VrOfnTfe67aK0XZ6q/5B6ztQZhkMzvuINJI5FEfibkys4XxO1r8lP90L0I5lVeV27FNvG6WDixL6k/Z4hSmG/kztCN9S8pZndOMFcTiDL4oxvOrkuIwndLxb9lCXy5FwF04OfBk0zGVHC4Ov6oBLnbr4sB48SgsaKDr4T/kGXZNO1VCUCeoj2USOrSONGTObCfQWdbliVAhfm2NFYxbDzMcarL7Csgj+x1J0cT48wKXlfbB1RszcfHzJqzY3DumUIoqqC0rWl86m5ht1rmg=; 20:tj1w5RgSa5Jwutr8tW7lFFUq7TwaxCDCuZj/h2BvodLwIOCzgTag0koL9NCQvxb/VIU/4bE5NpDzfAjui/dOkDymVb8CfktO+CSyAgpc3YWnqvNnGUWqvmrPX38oSuhH4Dwt2CGzkmX1LIWyMrtNUEjN9A57kcvuYDtA0ZCkNyZPVC0ATYLXbMHloJOcJ3mMpMWUmmq8Wj5j981VEyp/wwgbsn2cinJMj5o3N8fEkWelu0RHeeEoSK6Id8iJk8Gl94eZbUpRXBlg2Ce5awQsTLtb97zueMU3snM1QBlGOzMj1Rv5/VPvr9k6igpGLVJrA+PXaK687nOlkOOxkooUWLpR10OkRQVy4cAf1OlR/+dNTW/0KRsRF7fpHkEndq/ngQryUALOcvsfPlwf2PUwxQou7E4hSPm6OO3gPQ8jm2tOM3rrxVPMo0NWFJoG1QdGMcvuAMGmvW78MTqDWc7gfdLvrGmbBEeVB104HSHHynmNI5iOIBxn3ee3egZSiKaZ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13015025)(13023025)(13024025)(13018025)(13017025)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123560025)(20161123562025)(20161123558025)(20161123564025)(20161123555025)(6072148); SRVR:DM2PR07MB480; BCL:0; PCL:0; RULEID:; SRVR:DM2PR07MB480; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB480; 4:fckvhwQOrbNygDZq3EaWs6znuI1h5ek4RIMz0MvmzKbZCrKdMV1o7g/VRBMNFtjpPmGYU9VQtXP6l59atUhi5jjVSqL6hm8r7/g9a7dKD3RUiaH+H1zDAIf3G3jJJeC3jL0MaFwrMg81ycvUENHbPNEvv6TcyX9JEMqRMV2JJoFYq3aAO2AMAE6L0TcBgAI+obeUtESTC3DA9NAKOaeBeq86UDPbbwuWE8xrD0OaUBFWrXdJg3kEwbUUzNy9AQxCw9kM5SNYtwRksA1xsd8C01pF1ZGSvbpPyBEtrBSNyi/yoxYBo08uNsxFB1V64KpHsfrkUS5LctG5CIzB/EN3P7yZCDY3+Pg5bDmrl7uVrLE4PLCjR+g98ZbB+ppbEm6Hsv6fQ0lJEKqulwZKMzdcBnl/2Kol1HaUh+40bQvIeVOrbZ+51GorSYPesbszyFs9wXQJrXEuipkWhdijBHwqdDbrvEC+8jUDpJBtH1mpUF/8Hx3evzn4z3LbXCh7M2RIHXs6e23lUA10HymACql74Jt0X/8h3DHu0hTOWNasGXlZnLxsqnBoIHBZ90kcyv0h74BKBw3MfGOhGT2x2Vx2vlOTUh7jFmiTlo1Cm2ioH+YZQuHXF0vW+MQ0jal7NgREIe7TRzm0hHaZsfbli+g3f7GbZHqhKbzD4mEBd2JXPGlo4Huyztx60Hd7qj7udJ0wzsn03p1Vd5KEjqzYMO+5lrxQNIutN6PNUa8wax/gVzq6g5sTCLCf87lP66fNEFZ21a1bhYCBygC0EWJPUOAfJA== X-Forefront-PRVS: 02475B2A01 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR07MB480; 23:rX5hlDAuWhDWDpdf//oVoxohCAcXQ1vBpGPPC5jxCI?= =?us-ascii?Q?wpk6jmQ/+IvnekPUr2FnOl+RV4qsK3awdQhnPw4kZ2pZll/wEgWSRoW3JRtB?= =?us-ascii?Q?MvwImA4YoQrQmfFg6K1lZS4cCVGL0SXzrD+J4b+AjGl1CJNXLKZCBjV1dUk7?= =?us-ascii?Q?2nLRHjxzlbHKWqWjZ0KYkdJi9xfNCBpNUOsCiZzWyo0U+SiNCFR+vaJdlYck?= =?us-ascii?Q?x/5NLw0EQWr1HoKioQdHGTaBh5m4I4pUS4a4uBfW0Z23mWal/dbaTiyOHrQk?= =?us-ascii?Q?eDJ0kUrVjUTk1mzz+zFC+eLEuWJu+73uoROey10H7CK07h02FCbjNNADOs1a?= =?us-ascii?Q?u+WNGauWE2jgbkGATfOyUgU6RnizQ5kBQdrzzE6jkMs/FTlZpX02xph61M6m?= =?us-ascii?Q?TNt6glM2E6BpOjxfH9BZcwzxejKFpZAsRCzYxU/fnsnRnq/1jz2BKEuoOZwe?= =?us-ascii?Q?uQZRxkQlDpm1gP4khiZ5dzw1NNsUXJokCaPieKINm8qi67p9752h8eu6mwNt?= =?us-ascii?Q?T0G6vp7Bsd5MfsApHzEV9Yk1WTqXBTAV3Erv5QTaFOWq1Nh3Cr/UkhGZutdL?= =?us-ascii?Q?P5yWBePRuLY9/q0l6YYFEZg04K544Fts9pqsvwMgRFCrspOH5+qEZgMkGad0?= =?us-ascii?Q?s/jc3Re2SIuXEkSdPeFyJQZZAQ1oVY0gxCbQOQalLzlU7cR1kqpEYWJckMYM?= =?us-ascii?Q?2XXc3/3ke3iySUuU5cKym3LqJO38TxtqntwBM/ubjaorr4PzyoGcB25lPxwe?= =?us-ascii?Q?DA8G2x/3W3rG2hecZ72AQUP+hesPBI8zjfzKolG4RLHwiY5tzUnYU9axvE3O?= =?us-ascii?Q?h04P+f4fSsdiXNVjHeUe738P6+AvEi6HwyZ6p3nhXYRnEan4O6xTyUC9Kr4/?= =?us-ascii?Q?mdDcPvh6Pj9Uvc0aJGzm9tHcihQKyTdCPVb+j65GVLLGpu08UT8bdvKjC8Er?= =?us-ascii?Q?CROSWYJiVaDAP/K8Yd9Nyq1tjsh12uT2Hoo+qJn2OJinqdLVZLS9txL2a7qs?= =?us-ascii?Q?E=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB480; 6:2Hd3CVl2XyxNc6sjFGVy8zk15ywTt+0SFJ2gqM6jTMRDhZhSgHJR399NQnKSG9361e8p5hZewyOXEq76p7h2sTF6zR46k23Hd8wJ/YSyRiiM7djOIDNzILxkNcdRkC72GwBq/j/jJbw5APuLGS5FIJPT3HBFRo9O13taB9a2i5kI1FrzO/KOA9Lhz5+R771MCeYBTp0ECAritvKmtHEKOYuQf7TeiP2MsYpb28Wd6DLpYbiJxOdahbI4S9j7gTlPurHl/6jjUScWiS2fjhLt7CvhAbh8xPoBiNPXVQK/6uwMx/HL0TGv2UYe0mRdpU4xgVLRNeSad7O4k9uoUC+XQjrkLb8w4w96CaNV4nty1uc2kNYaM78Fpv62v8fn5csEZtxbzXaGpe6CRe2SCJseTw==; 5:4QDqjob/1ZiADwfRI4BxZUyxYpaKfFSwUgyT12hajkIUkX9BWAATWlUlcw4pm4Hd62q0fWxcMa4nq2CURP9JSdIMPM8HhAs3xH5K0/k+1fI3Uoh7kG0Lt6ILqlQCcLbbSa7tJuxu19AOJIm74LPaPw==; 24:WWZUyWNBxKb6+YUmwfEkqOdBgqXgN/2HpstRc+Lj3wRQqIr+OibAh3vPx2LGqLeepYXb/FToYtMOFFy4CIAvx0wQivFwMR7XOo28+DkU6cI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB480; 7:sT00q+DdmdWf5qo7ZhFjV4t+mlV7uIp9639wXOUxa4XAAejJwrSKCWzU7a94e954MBU9myx1z0grFfBfGDb1TlUXBGMd9dLpQYwsj/H+3E96TJ0qFuGrIwdgfJbVs3D6joe/ooMIBvC9UmOOBsVh2xCaFMOLVFoCZ4Eb4hHsJlsyp6Ytu3nYbcnsQINdmnr9XsR7Pyu+FzIG+qSjN7bGniPIpYFUc8kggcLTihW36y8RhoDX/apchk4yjgDjcj9hc4Ah4IoW0ceq6WtteMGiGuz/B/xvi5q/wgORWr4wJxNM0owiOzogNXBeclx7+N53pHqhy2Hf+KURMAUhThN3Aw== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2017 16:49:13.0115 (UTC) X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR07MB480 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran The main lock that needs to be held for CMD or TMR submission to upper layer is the sess_lock. The sess_lock is used to serialize cmd submission and session deletion. The addition of hardware_lock being held is not necessary. This patch removes hardware_lock dependency from CMD/TMR submission. Use hardware_lock only for error response in this case. Path1 CPU0 CPU1 ---- ---- lock(&(&ha->tgt.sess_lock)->rlock); lock(&(&ha->hardware_lock)->rlock); lock(&(&ha->tgt.sess_lock)->rlock); lock(&(&ha->hardware_lock)->rlock); Path2/deadlock *** DEADLOCK *** Call Trace: dump_stack+0x85/0xc2 print_circular_bug+0x1e3/0x250 __lock_acquire+0x1425/0x1620 lock_acquire+0xbf/0x210 _raw_spin_lock_irqsave+0x53/0x70 qlt_sess_work_fn+0x21d/0x480 [qla2xxx] process_one_work+0x1f4/0x6e0 Cc: Cc: Bart Van Assche Reported-by: Bart Van Assche Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_target.c | 41 +++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index a78c3e9bcb57..989f931af156 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -5727,30 +5727,23 @@ static void qlt_abort_work(struct qla_tgt *tgt, } } - spin_lock_irqsave(&ha->hardware_lock, flags); - - if (tgt->tgt_stop) - goto out_term; - rc = __qlt_24xx_handle_abts(vha, &prm->abts, sess); + ha->tgt.tgt_ops->put_sess(sess); + spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); + if (rc != 0) goto out_term; - spin_unlock_irqrestore(&ha->hardware_lock, flags); - if (sess) - ha->tgt.tgt_ops->put_sess(sess); - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); return; out_term2: - spin_lock_irqsave(&ha->hardware_lock, flags); + if (sess) + ha->tgt.tgt_ops->put_sess(sess); + spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); out_term: + spin_lock_irqsave(&ha->hardware_lock, flags); qlt_24xx_send_abts_resp(vha, &prm->abts, FCP_TMF_REJECTED, false); spin_unlock_irqrestore(&ha->hardware_lock, flags); - - if (sess) - ha->tgt.tgt_ops->put_sess(sess); - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); } static void qlt_tmr_work(struct qla_tgt *tgt, @@ -5770,7 +5763,7 @@ static void qlt_tmr_work(struct qla_tgt *tgt, spin_lock_irqsave(&ha->tgt.sess_lock, flags); if (tgt->tgt_stop) - goto out_term; + goto out_term2; s_id = prm->tm_iocb2.u.isp24.fcp_hdr.s_id; sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id); @@ -5782,11 +5775,11 @@ static void qlt_tmr_work(struct qla_tgt *tgt, spin_lock_irqsave(&ha->tgt.sess_lock, flags); if (!sess) - goto out_term; + goto out_term2; } else { if (sess->deleted) { sess = NULL; - goto out_term; + goto out_term2; } if (!kref_get_unless_zero(&sess->sess_kref)) { @@ -5794,7 +5787,7 @@ static void qlt_tmr_work(struct qla_tgt *tgt, "%s: kref_get fail %8phC\n", __func__, sess->port_name); sess = NULL; - goto out_term; + goto out_term2; } } @@ -5804,17 +5797,19 @@ static void qlt_tmr_work(struct qla_tgt *tgt, unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun); rc = qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0); - if (rc != 0) - goto out_term; - ha->tgt.tgt_ops->put_sess(sess); spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); + + if (rc != 0) + goto out_term; return; +out_term2: + if (sess) + ha->tgt.tgt_ops->put_sess(sess); + spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); out_term: qlt_send_term_exchange(vha, NULL, &prm->tm_iocb2, 1, 0); - ha->tgt.tgt_ops->put_sess(sess); - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); } static void qlt_sess_work_fn(struct work_struct *work)