From patchwork Tue Mar 26 07:38:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 10870521 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 C6EA415AC for ; Tue, 26 Mar 2019 07:39:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B300228FEC for ; Tue, 26 Mar 2019 07:39:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A750E2907D; Tue, 26 Mar 2019 07:39:52 +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 A454428FEC for ; Tue, 26 Mar 2019 07:39:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731114AbfCZHjv (ORCPT ); Tue, 26 Mar 2019 03:39:51 -0400 Received: from mail-eopbgr700083.outbound.protection.outlook.com ([40.107.70.83]:27424 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730935AbfCZHju (ORCPT ); Tue, 26 Mar 2019 03:39:50 -0400 Received: from DM5PR07CA0109.namprd07.prod.outlook.com (2603:10b6:4:ae::38) by CY1PR07MB2540.namprd07.prod.outlook.com (2a01:111:e400:c636::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.19; Tue, 26 Mar 2019 07:39:48 +0000 Received: from DM3NAM05FT017.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::200) by DM5PR07CA0109.outlook.office365.com (2603:10b6:4:ae::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.19 via Frontend Transport; Tue, 26 Mar 2019 07:39:48 +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 DM3NAM05FT017.mail.protection.outlook.com (10.152.98.126) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1750.4 via Frontend Transport; Tue, 26 Mar 2019 07:39:48 +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, 26 Mar 2019 00:39:31 -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 x2Q7dVDb026871; Tue, 26 Mar 2019 00:39:31 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x2Q7dVO4026870; Tue, 26 Mar 2019 00:39:31 -0700 From: Saurav Kashyap To: CC: , Subject: [PATCH v2 11/26] qedf: missing kref_put in qedf_xmit() Date: Tue, 26 Mar 2019 00:38:43 -0700 Message-ID: <20190326073858.26792-12-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190326073858.26792-1-skashyap@marvell.com> References: <20190326073858.26792-1-skashyap@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131980595887626167;(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)(346002)(396003)(136003)(39860400002)(376002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(305945005)(446003)(36906005)(316002)(2616005)(4744005)(16586007)(356004)(6666004)(4326008)(36756003)(6862004)(53936002)(97736004)(42186006)(14444005)(5660300002)(69596002)(81156014)(68736007)(81166006)(85426001)(80596001)(8676002)(48376002)(476003)(126002)(51416003)(26826003)(50226002)(8936002)(105606002)(2351001)(106466001)(1076003)(50466002)(76176011)(26005)(498600001)(2906002)(47776003)(86362001)(486006)(54906003)(11346002)(87636003)(336012);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR07MB2540;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: 8b33343f-756c-4b53-e26c-08d6b1be3996 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600127)(711020)(4605104)(2017052603328);SRVR:CY1PR07MB2540; X-MS-TrafficTypeDiagnostic: CY1PR07MB2540: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 09888BC01D X-Microsoft-Antispam-Message-Info: 8OgbXoVJ8F3F7e7iJJlSrT2I049loFbMEMqnZB+j6NnKd4AYu3mAx1J77k49iip0FSJE+w+236ioaZr4u0XzwknoUOaDXLOBoRne4zVLtg2FRcbg+NAGFqPrlWeahYJmqQMwUnUYMpJhRRxf6Thgqj4M8M9PAJ7OX0wIDcbvid4E3M4XTfA8WvMAxe8r8PzjS+YXZB1zx8ZTRH30mM5y3zoGsF1uBSKiULnYp28M5ZZ2nT3l30CADp/Jir0lRGkAuDJfBYN35TQJ1X5336yo9kvC4rAt7n4+N8aMKJ/3LVQkeY7OoEB8ELY6F5tHqtr75/tcfGVlts+ssdufZLAH6wqfGxgHMw8xq+U2AZWgp6rk26sE80zHYREiFm/goR/TRJLah+ADXohxZdbTH0R9Y5KIC80W8jMQ73m00V6VC1A= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2019 07:39:48.4143 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8b33343f-756c-4b53-e26c-08d6b1be3996 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: CY1PR07MB2540 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: Hannes Reinecke qedf_xmit() calls fc_rport_lookup(), but discards the returned rdata structure almost immediately without decreasing the refcount. This leads to a refcount leak and the rdata never to be freed. Signed-off-by: Hannes Reinecke Signed-off-by: Saurav Kashyap --- drivers/scsi/qedf/qedf_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index f84552e..fb9c288 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -971,8 +971,10 @@ static int qedf_xmit(struct fc_lport *lport, struct fc_frame *fp) "Dropping FCoE frame to %06x.\n", ntoh24(fh->fh_d_id)); kfree_skb(skb); rdata = fc_rport_lookup(lport, ntoh24(fh->fh_d_id)); - if (rdata) + if (rdata) { rdata->retries = lport->max_rport_retry_count; + kref_put(&rdata->kref, fc_rport_destroy); + } return -EINVAL; } /* End NPIV filtering */