From patchwork Tue Apr 2 21:24:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Madhani X-Patchwork-Id: 10882361 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 8FF10922 for ; Tue, 2 Apr 2019 21:26:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AF01288BA for ; Tue, 2 Apr 2019 21:26:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F50B288D2; Tue, 2 Apr 2019 21:26:17 +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 1E0AB288BA for ; Tue, 2 Apr 2019 21:26:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726083AbfDBV0Q (ORCPT ); Tue, 2 Apr 2019 17:26:16 -0400 Received: from mail-eopbgr710083.outbound.protection.outlook.com ([40.107.71.83]:8734 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725990AbfDBV0Q (ORCPT ); Tue, 2 Apr 2019 17:26:16 -0400 Received: from DM5PR07CA0047.namprd07.prod.outlook.com (2603:10b6:3:16::33) by BN3PR07MB2529.namprd07.prod.outlook.com (2a01:111:e400:7bbf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.22; Tue, 2 Apr 2019 21:26:12 +0000 Received: from CO1NAM05FT022.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::207) by DM5PR07CA0047.outlook.office365.com (2603:10b6:3:16::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.18 via Frontend Transport; Tue, 2 Apr 2019 21:26:11 +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 CO1NAM05FT022.mail.protection.outlook.com (10.152.96.130) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1771.6 via Frontend Transport; Tue, 2 Apr 2019 21:26:11 +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; Tue, 2 Apr 2019 14:25:06 -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 x32LP6gm028544; Tue, 2 Apr 2019 14:25:06 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x32LP6iC028543; Tue, 2 Apr 2019 14:25:06 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 10/15] qla2xxx: Cleanup fcport memory to prevent leak Date: Tue, 2 Apr 2019 14:24:29 -0700 Message-ID: <20190402212434.28469-11-hmadhani@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190402212434.28469-1-hmadhani@marvell.com> References: <20190402212434.28469-1-hmadhani@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131987139717850726;(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)(396003)(39860400002)(136003)(346002)(376002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(81156014)(68736007)(81166006)(305945005)(47776003)(8676002)(50226002)(85426001)(336012)(2906002)(8936002)(105606002)(86362001)(4326008)(53936002)(446003)(106466001)(36756003)(356004)(6666004)(51416003)(80596001)(48376002)(50466002)(87636003)(76176011)(126002)(476003)(2616005)(69596002)(11346002)(498600001)(26826003)(26005)(1076003)(42186006)(16586007)(316002)(5660300002)(486006)(97736004)(54906003)(36906005)(110136005);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR07MB2529;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Fail;LANG:en;PTR:InfoDomainNonexistent;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4835f7e2-09f8-4bbb-ddf8-08d6b7b1d42e X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600139)(711020)(4605104)(2017052603328);SRVR:BN3PR07MB2529; X-MS-TrafficTypeDiagnostic: BN3PR07MB2529: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0995196AA2 X-Microsoft-Antispam-Message-Info: bntH4x+ca0/Wwv9I1og8OK847Svhcg5N+XDZzBBThQYdakoMOPmySFGG3wo1fKvLP6hMm9gURyu+DHuOgLPdloU+RkyguPfdQjWlH3IdBTcozZCGB252UOQ9JpgJQJBFPcTeYUxZNHXi4cDK5oCkNikKAvCl9p8WJV2zLj/IqTSNjlavdunakManr6cGMhc8PoSUGrxg9iEHywTKsvoogt0u82r8QyRYO1YVS8/VvYbYoRmg/rne1mzaJdLzgeHnXX4mhLdnQC/MIACbPiuctqyBuXMiF4TyDSdMgXNPodrKlqP2dHgu5xH2x6iE2bxon09gVqydoxhy8QJHDhcWb/d6c7bqq8UippAvZ3MzrjrUrlM60w5J3E7x+ttfpPNBCz+ZBumQoI2GOwdx5E9zVygFOh8PUxE1wibk9onQINk= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2019 21:26:11.3567 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4835f7e2-09f8-4bbb-ddf8-08d6b7b1d42e 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: BN3PR07MB2529 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 ab212b4853a1..7bdf1e45d891 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 04c2309a6369..09e0e9d04205 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