From patchwork Fri Jan 25 07:23:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Madhani X-Patchwork-Id: 10780717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6C54922 for ; Fri, 25 Jan 2019 07:25:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C6832EF10 for ; Fri, 25 Jan 2019 07:25:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 803BD2EF78; Fri, 25 Jan 2019 07:25:27 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 0D9E02EF10 for ; Fri, 25 Jan 2019 07:25:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728469AbfAYHZ0 (ORCPT ); Fri, 25 Jan 2019 02:25:26 -0500 Received: from mail-eopbgr790070.outbound.protection.outlook.com ([40.107.79.70]:20256 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727745AbfAYHZ0 (ORCPT ); Fri, 25 Jan 2019 02:25:26 -0500 Received: from DM5PR07CA0101.namprd07.prod.outlook.com (2603:10b6:4:ae::30) by DM6PR07MB4763.namprd07.prod.outlook.com (2603:10b6:5:a1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.18; Fri, 25 Jan 2019 07:25:24 +0000 Received: from DM3NAM05FT014.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::200) by DM5PR07CA0101.outlook.office365.com (2603:10b6:4:ae::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1558.18 via Frontend Transport; Fri, 25 Jan 2019 07:25:24 +0000 Authentication-Results: spf=fail (sender IP is 199.233.58.38) smtp.mailfrom=marvell.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=marvell.com; Received-SPF: Fail (protection.outlook.com: domain of marvell.com does not designate 199.233.58.38 as permitted sender) receiver=protection.outlook.com; client-ip=199.233.58.38; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (199.233.58.38) by DM3NAM05FT014.mail.protection.outlook.com (10.152.98.123) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1580.2 via Frontend Transport; Fri, 25 Jan 2019 07:25:23 +0000 Received: from dut1171.mv.qlogic.com (10.112.88.18) by CAEXCH02.caveonetworks.com (10.67.98.110) with Microsoft SMTP Server (TLS) id 14.2.347.0; Thu, 24 Jan 2019 23:24:22 -0800 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 x0P7OKVH003584; Thu, 24 Jan 2019 23:24:20 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x0P7OKks003582; Thu, 24 Jan 2019 23:24:20 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 09/13] qla2xxx: Prevent memory leak for CT req/rsp allocation Date: Thu, 24 Jan 2019 23:23:47 -0800 Message-ID: <20190125072351.3504-10-hmadhani@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190125072351.3504-1-hmadhani@marvell.com> References: <20190125072351.3504-1-hmadhani@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131928747241842661;(abac79dc-c90b-41ba-8033-08d666125e47);(abac79dc-c90b-41ba-8033-08d666125e47) X-Forefront-Antispam-Report: CIP:199.233.58.38;IPV:CAL;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(39860400002)(346002)(396003)(136003)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(1076003)(8676002)(105606002)(53936002)(50226002)(305945005)(106466001)(97736004)(336012)(486006)(2906002)(47776003)(86362001)(80596001)(26005)(69596002)(446003)(11346002)(476003)(126002)(2616005)(81166006)(81156014)(87636003)(16586007)(6666004)(85426001)(498600001)(356004)(36906005)(76176011)(51416003)(50466002)(316002)(4326008)(42186006)(14444005)(68736007)(48376002)(36756003)(26826003)(8936002)(110136005)(54906003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR07MB4763;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Fail;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;DM3NAM05FT014;1:oGKDpJ6PJzz2PFjXYDX77/ErQnstgHR+WwsyWBpOj0KKFYZwXKyohFgD/rXzz097T4TvYm/hd/hSTNzBE5E3Ir+IXaK8Qr0xDHe0P65f2XqJ18sI9xk8Dz1AtYYHVCj/yzUq8DCU83+3Dt6426Je/w== X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4f19f82-9498-4622-cfa0-08d682964574 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600110)(711020)(4605077)(2017052603328);SRVR:DM6PR07MB4763; X-Microsoft-Exchange-Diagnostics: 1;DM6PR07MB4763;3:er9jd19yZntvLi0cQwxS+LvabhftdslvqdFw/M2wWVGNDyBuRnm/X9PlcbbFPhXP0OArSKnGt5t1Y0dJTi7w9Pm0Q/zT2pjur3OwopBUnjjueD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6ZPEFutC1Ysns7zTSwBDtOzcUjdsDO14cMtaqncYz3COqenriqmaijvmtoXj12s1P7Ie5LJKo1TmKk7hwaBONt9k1YKI2bUCGghZ4dAI+3zVJeut2iBZsqwF8re9s0vaVKHMDM5zikcb56uQEt4FCuBYSC8YfEEDzPiTmyXvYyrXmEvppegEVOSuo1ZR0ftShUyba8J3juafzni6ud+R8J6sKY8ovm1pT4f/zjFWg24Ma4arscTokPq8TMd62R6TIy4T5tRm4qgF0WIhV7X9+2o5J1IuRGT5K1N7EYslWtNm9Bvw9q2wvoNrQg==;5:tEPp7zRLOwsXYjcqGQi3N6zG1m2XnhdhERIoSjfAevSDujTHdfllusOnksSZwAt102Va3j+oN5CcqBZzxDwYn5Tg40tR7j8pT3z03rlveTlMsLRuHNRt+VQqHZP4MdVQJoe7uQX+Cpc9iJ9QdyEnBgEu3Xr0CTpH2FMUTek8d/kBEGzKFPwT3HO05ErCdZ8eizSGMmRA1mazyJe71mLA3w==;7:TBxNafeO4lPX7tJDbfTsdYY8MNborjnwvTIgFGAPzNnIAxiiploMMfMpO2R0vL3L3f4tVtwskClckSTp2SUuFODM1ovPRRFc0jvGjhdHMpFJ/Uj4iQstfDg3jAgBOrPd4nBFrRMjf7Csxx4tdsIdHA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2019 07:25:23.8079 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4f19f82-9498-4622-cfa0-08d682964574 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[199.233.58.38];Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR07MB4763 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran This patch fixes memory leak by releasing DMA memory in case CT request and response allocation fails. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_gs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index 90cfa394f942..4aada6b37076 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -4157,7 +4157,8 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp) spin_lock_irqsave(&vha->work_lock, flags); vha->scan.scan_flags &= ~SF_SCANNING; spin_unlock_irqrestore(&vha->work_lock, flags); - goto done_free_sp; + qla2x00_rel_sp(sp); + return rval; } sp->u.iocb_cmd.u.ctarg.req_size = GPN_FT_REQ_SIZE; @@ -4175,7 +4176,13 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp) spin_lock_irqsave(&vha->work_lock, flags); vha->scan.scan_flags &= ~SF_SCANNING; spin_unlock_irqrestore(&vha->work_lock, flags); - goto done_free_sp; + dma_free_coherent(&vha->hw->pdev->dev, + sp->u.iocb_cmd.u.ctarg.req_allocated_size, + sp->u.iocb_cmd.u.ctarg.req, + sp->u.iocb_cmd.u.ctarg.req_dma); + sp->u.iocb_cmd.u.ctarg.req = NULL; + qla2x00_rel_sp(sp); + return rval; } sp->u.iocb_cmd.u.ctarg.rsp_size = rspsz;