From patchwork Thu Mar 28 17:10:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Madhani X-Patchwork-Id: 10875463 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 E8BBC13B5 for ; Thu, 28 Mar 2019 17:12:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6B3728CDF for ; Thu, 28 Mar 2019 17:12:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C511128ECB; Thu, 28 Mar 2019 17:12:01 +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 661A828CDF for ; Thu, 28 Mar 2019 17:12:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727622AbfC1RMA (ORCPT ); Thu, 28 Mar 2019 13:12:00 -0400 Received: from mail-eopbgr790074.outbound.protection.outlook.com ([40.107.79.74]:37424 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727621AbfC1RMA (ORCPT ); Thu, 28 Mar 2019 13:12:00 -0400 Received: from DM5PR07CA0033.namprd07.prod.outlook.com (2603:10b6:3:16::19) by CO2PR07MB2533.namprd07.prod.outlook.com (2603:10b6:102:17::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.15; Thu, 28 Mar 2019 17:11:58 +0000 Received: from BY2NAM05FT014.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::202) by DM5PR07CA0033.outlook.office365.com (2603:10b6:3:16::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.17 via Frontend Transport; Thu, 28 Mar 2019 17:11:58 +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 BY2NAM05FT014.mail.protection.outlook.com (10.152.100.151) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1771.6 via Frontend Transport; Thu, 28 Mar 2019 17:11:57 +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, 28 Mar 2019 10:10:49 -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 x2SHAmD6026500; Thu, 28 Mar 2019 10:10:48 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x2SHAmCQ026499; Thu, 28 Mar 2019 10:10:48 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 10/15] qla2xxx: Cleanup fcport memory to prevent leak Date: Thu, 28 Mar 2019 10:10:07 -0700 Message-ID: <20190328171012.26425-11-hmadhani@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190328171012.26425-1-hmadhani@marvell.com> References: <20190328171012.26425-1-hmadhani@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131982667180255734;(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)(39860400002)(396003)(346002)(136003)(376002)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(42186006)(36756003)(305945005)(85426001)(53936002)(106466001)(47776003)(316002)(105606002)(16586007)(2906002)(68736007)(80596001)(97736004)(69596002)(126002)(476003)(48376002)(26005)(50466002)(1076003)(6666004)(86362001)(5660300002)(446003)(336012)(486006)(2616005)(11346002)(87636003)(498600001)(81166006)(110136005)(50226002)(26826003)(4326008)(54906003)(8676002)(356004)(81156014)(51416003)(76176011)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR07MB2533;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Fail;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76e59e6d-e7db-4abd-5b9c-08d6b3a07c40 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600127)(711020)(4605104)(2017052603328);SRVR:CO2PR07MB2533; X-MS-TrafficTypeDiagnostic: CO2PR07MB2533: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0990C54589 X-Microsoft-Antispam-Message-Info: zPBm6teZKRTz2FQtfWuIdAE1yI5BewzUmUzAyE5KdS5X8saxDGJedc7XfTpBAoNyquJrO8v5FlIFC+SlNs4t/DxA0MqhzOS6Ss/YUI1vcpNAzkHWoSMUmJeLlpDrHZGAGD7epCFLWujS4jaarGqJGUY0o9mzLHYJQ6EslOtRSK4gqQCxNF0LP7hy+vns+eQPHHMxek2HAZZ6a5rapwuwMQZmki7jTv2Oo/OvuHEVsMb8X3vx+cIpVSdKPmZwjKo2tIkBRj90dWcgDQ37JJ9K7/wGTPpPgUjnk4UmCI0oeT1WYwPmC6wkUPNu74mwVuovM4KGMCeeoYhyzuRYzsl7xkR+YMa57JKpsr1YkRrL4XuowC2pLAxKN2NgSA/cegm/66VjezEjgz9bcrBr88hjuF1ZUpQD08OkfKhn1krbqvM= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2019 17:11:57.4120 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76e59e6d-e7db-4abd-5b9c-08d6b3a07c40 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: CO2PR07MB2533 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 cleanup fcport list and loopid in one place and iterate through for loop. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_init.c | 2 ++ drivers/scsi/qla2xxx/qla_os.c | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 8187791b5bd0..fe1f5f1e6635 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -4821,6 +4821,8 @@ qla2x00_free_fcport(fc_port_t *fcport) fcport->ct_desc.ct_sns = NULL; } + list_del(&fcport->list); + qla2x00_clear_loop_id(fcport); kfree(fcport); } diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 0e5213f24e43..71ff35646bfe 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3907,11 +3907,8 @@ void qla2x00_free_fcports(struct scsi_qla_host *vha) { fc_port_t *fcport, *tfcport; - list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { - list_del(&fcport->list); - qla2x00_clear_loop_id(fcport); - kfree(fcport); - } + list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) + qla2x00_free_fcport(fcport); } static inline void