From patchwork Wed May 11 00:13:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9064121 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D5F78BF29F for ; Wed, 11 May 2016 00:13:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2F4A20172 for ; Wed, 11 May 2016 00:13:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0724B20160 for ; Wed, 11 May 2016 00:13:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752403AbcEKAN3 (ORCPT ); Tue, 10 May 2016 20:13:29 -0400 Received: from mail-bn1bon0093.outbound.protection.outlook.com ([157.56.111.93]:15168 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751650AbcEKAN1 (ORCPT ); Tue, 10 May 2016 20:13:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandiskcorp.onmicrosoft.com; s=selector1-sandisk-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=MCsD0wk8Ybinohd5UUNDuskJ862aGUlCpzfZBlEknHg=; b=WyZm4ZUF9Ogw8J6KjuzhfWV1OU/m0R7VSSjmV4R+LGkZxen9B7d52JwV2bC/gTyuAL4WzUZ7Y7HBrOgBGtEs0DKTxG5pRghd9pEMFx4OHWe4G0JOCwSLAgN37+pPVUnwu4+mHzSuMNi6zxCCNNCB/MxUMpes/ScoqUdII9rXHz0= Received: from BN1PR02CA0012.namprd02.prod.outlook.com (10.141.56.12) by BLUPR0201MB1857.namprd02.prod.outlook.com (10.162.239.139) with Microsoft SMTP Server (TLS) id 15.1.492.11; Wed, 11 May 2016 00:13:24 +0000 Received: from BL2FFO11FD049.protection.gbl (2a01:111:f400:7c09::146) by BN1PR02CA0012.outlook.office365.com (2a01:111:e400:2a::12) with Microsoft SMTP Server (TLS) id 15.1.492.11 via Frontend Transport; Wed, 11 May 2016 00:13:24 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.21 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.21; helo=milsmgep15.sandisk.com; Received: from milsmgep15.sandisk.com (63.163.107.21) by BL2FFO11FD049.mail.protection.outlook.com (10.173.161.211) with Microsoft SMTP Server (TLS) id 15.1.492.8 via Frontend Transport; Wed, 11 May 2016 00:13:21 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com (Unknown_Domain [172.22.12.162]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id CD.01.03047.D7872375; Tue, 10 May 2016 17:10:38 -0700 (PDT) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.279.2; Tue, 10 May 2016 17:13:21 -0700 X-AuditID: ac160c69-5f3ff70000000be7-22-5732787d9dad Received: from exp-402881.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id E1.7C.02566.12972375; Tue, 10 May 2016 17:13:21 -0700 (PDT) Subject: [PATCH 2/6] IB/srp: Fix a memory descriptor leak in an error path To: Doug Ledford References: <573278D9.4050908@sandisk.com> CC: Christoph Hellwig , Sagi Grimberg , Laurence Oberman , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <57327921.9030306@sandisk.com> Date: Tue, 10 May 2016 17:13:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <573278D9.4050908@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrELMWRmVeSWpSXmKPExsWyRoxnkW5dhVG4wbL9LBYvz39gtVi5+iiT xbNDvSwW5z+8YrJY9/o9iwOrx/l7G1k8dt9sYPN4v+8qm8fnTXIBLFFcNimpOZllqUX6dglc GTO7jrEU7OOqmL6nh6mB8QtHFyMnh4SAiUTDwVvMXYxcHEICc5kk1q9+xwLh7GCUmNmxiwWm 6krHC1aIxFJGiV1vzzCBJIQFvCR2XVjPDmKLCKhJbHq1CMwWEtCSWNk+H6yBWWA1o8SXZa/A GtgEjCS+vZ8JNJWDgxeo6P2qXJAwi4CqxNp9J1hBbFGBCInV664xg9i8AoISJ2c+ATuCU0Bb 4v+u/2wgrcwCmhLrd+mDhJkF5CW2v50D9oGEwF5WiT+v1zNC3KAucXLJfKYJjMKzkIyahdA+ C0n7AkbmVYxiuZk5xbnpqQWGpnrFiXkpmcXZesn5uZsYITGRuYPx7hPvQ4wCHIxKPLw7uAzD hVgTy4orcw8xSnAwK4nw5hQbhQvxpiRWVqUW5ccXleakFh9ilOZgURLndbv3JUxIID2xJDU7 NbUgtQgmy8TBKdXAWPHeWbbPR7/PVnLfDoMtV3R7ru2bmZHB/vFlhd/7NQveSjy3qGe3SPrt 51TncmTB2T+Mi806l/LMaHxfLW9ulnUi98fkvp2ruKxWO7rLNXqyB++6cPnd7RfyhTr7/xmk 9j91v/vZiYsxpWTGcs3F953iHHJWlnxfJstanLjd9VL0szcG+2oClFiKMxINtZiLihMB/s7Q N4UCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJJMWRmVeSWpSXmKPExsXCtZEjRVex0ijcYONVbouX5z+wWqxcfZTJ 4tmhXhaL8x9eMVmse/2exYHV4/y9jSweu282sHm833eVzePzJrkAligum5TUnMyy1CJ9uwSu jJldx1gK9nFVTN/Tw9TA+IWji5GTQ0LAROJKxwvWLkYuDiGBxYwSX8/NZgZJCAt4Sey6sJ4d xBYRUJPY9GoRmC0koCWxsn0+WAOzwGpGiXt9vxhBEmwCRhLf3s9k6WLk4OAFKnq/KhckzCKg KrF23wlWEFtUIEJi9bprYPN5BQQlTs58wgJicwpoS/zf9Z8NxGYWUJf4M+8SM4QtL7H97Rzm CYx8s5C0zEJSNgtJ2QJG5lWMYrmZOcW56ZkFhoZ6xYl5KZnF2XrJ+bmbGMGByRm5g/HpRPND jEwcnFINjEwPSrj/OZU7st4IkpN0PXr+Sf2KqW+T3HuC6qV1eA8/qkn+Fv09++XS2sy/D+8+ juz+zD7x/ozSho7CbX9d+6aZvXf4Ouv18coZyw/94xO/oiN+uUUyoKbijOX09c1XO8/VWYeU aL76n2na/2NhxEzBC1+8dZ68nrnz+ownB/zbLjCtWHj7fr8SS3FGoqEWc1FxIgDCCgoM/AEA AA== X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(9170700003)(5003600100002)(36756003)(53416004)(47776003)(2906002)(86362001)(189998001)(110136002)(4001350100001)(8936002)(77096005)(59896002)(2950100001)(81166006)(50986999)(117636001)(99136001)(92566002)(87936001)(19580405001)(19580395003)(87266999)(54356999)(76176999)(65816999)(50466002)(106466001)(23676002)(11100500001)(65806001)(1220700001)(586003)(65956001)(229853001)(6806005)(4326007)(230700001)(5008740100001)(122286003)(62816006); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0201MB1857; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD049; 1:wRuurJ4ZQZ2zd6wAVa0a9h8Qf3tdMkDE+HibkvDrNuRyrA++qimS1JcPDkbEOViVZsymhTxPkz9zRVH/hbauPwnuhc8eU1966ksomZXh2DhVYS9LI7Ou8n2sDeF/Il6RTs7ou36K+CbJZ40aS4Mc+6itO1G0wjAkXaTfHvomJtpkiWgUqwtDuX3GQaXz/eUCMS7jJ603cN2lsaHRZ4TJgP+aqiOxGTHvz0vPjMPPd9GRSTPH6bk8VLcwaeWfK5VD2TmCiUUiLn6GenCNURIuLsp8RKlW3szvNjSqbgqwKiSVE17MGa+M6KAyYFFtfmqxJL9jAQ1u2pguh/4CpSntq59XU4SzFt+Tee4/hzIsCK1cc0Hc7LTmMvNrY3FvhKUJlPIFEqzaPDYLWfKaacjU8QxJUcildc/TVyj+HDeTjDB2lroWtrJATjFvH3otHs73 X-MS-Office365-Filtering-Correlation-Id: 36a412fb-2711-4b4d-4565-08d379311058 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0201MB1857; 2:mYD4cdYEgSteX32AeGKwwpSuphu6w0rQKGovVq04syipJcx0FYe8klCZdMxwkTMlrohsVw7BaIhoQl/u9IuMOlQtmxy75FBslTRZd+36+Ac48T9rrcGuf6bLKAy/z8rbSOc3czRV9/dfn5lJyBHqcXJo5SYjr1KDRmImZRlArS13vy8JVKkUg5WqZixsVXVz; 3:cmTwdF0w9p7l0Ky3D1w+nKGYZbqZ1bEkHdWhvTmsO7wtL29Pczy5cRyPufcUKzEyZoLgtMrnO6qA/5DW+id8QAFMOpcGgCN0WeoHaESnee2Qhw9pWQK+Zw/zV2r0Sj2LXyKH5iLhr8T1og+VPrU8pcfvj/KcoVbR13tGqyIev/OinU5TLoKmj+X3SXpaKh+BhKCnHuOPlVnsRz8ZDrHOGaApEy552vzsOAKg1ICOUOJNsxfMrZjlc1S8k07iDs5hMZCAk/AsqFAOp1gxDiXcHA==; 25:2G9mib6Lc275o64mIk9CM6YktdM8LDEXmf/fTTR9Ak0iRLTUtMST70x9ciTMBExwqa216x7pxKXiH8e31BM5wi34RNcwgwl8uObsK//fcUF9bwnuKFO7L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PUoCmJ1qFl2QpjaWfMwOsoL9ULA1+DRhpMqQqmYMX+O2tVm2VKSwlJJwGXUVr6VGG3ronI+wucd44ezGEc9RGpuwB1F181PrHNcf56Ab+mTOsSJl1u7+3H5IRrmNo37iY2JpFAvKasqt+J3nmORcyJk29oFddLDbeZWrK5vbqrRUg6PPzgiykdM/Y8nbWtU7aekch5jlmoZ7phYxfRidU0FZu1lV+ZfL7nL7YVcMUYmc/JT/SyE+gxaPhHTCv6XzJCgZmT3znPAV1hD/2CDnBj4MMMCPWQHfh41ati82Fd1Kny34DeZ6K3CPoQ6J +5ztlG0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13016025)(13018025)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:BLUPR0201MB1857; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0201MB1857; X-Forefront-PRVS: 0939529DE2 X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTFVQUjAyMDFNQjE4NTc7MjM6bkZYdGJXM0UwNFZLUHVsZVk5U2NIbkND?= =?utf-8?B?Nkp5V2Zqdkl1bEk5d1ZDbHdrVy9yN250WmE1K215R3h4OC92anhtVExreEo2?= =?utf-8?B?T0k1NUdFMGY1OVhZMmk2OUR4QjRqMmJheFhpSm1aU01oWG94ZjNqNTRIVnVC?= =?utf-8?B?aVowUnFpVWh3VTcrNDJkZFhkMTN0L3lscDZlRGd5MkxBVWV6ZDlENXNiT0Fn?= =?utf-8?B?UVBiaVRaTEx0NWhWS01XZHVTMVBpVzl2WXJ1OFRPWnhZdUdvcVlxU2VaK3Vy?= =?utf-8?B?Tkl5QjJBRVQ5NGVTdHRDeEdXa214c1NhZDMycVVRbm1hZURKTnlwYkNOSU1y?= =?utf-8?B?MGdzZnk0Tm1jSTdBdUE3amp2UlZtUFJCOTNhN0N3clo2UDgrWWoybWlxVlpr?= =?utf-8?B?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kXitB2H6JfZ5IfSpm6VBoaYiH8LF381buYHg3E/u/ejF4XAphTlpmhWf72iTWoF9a SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2016 00:13:21.8334 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.21]; Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0201MB1857 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If an error occurs after srp_fr_pool_get() succeeded and before the descriptor is stored in srp_map_state (*state->fr.next++ = desc) then srp_unmap_data() won't free the newly allocated memory descriptor. Hence free the descriptor explicitly. Fixes: f7f7aab1a5c0 ("IB/srp: Convert to new registration API") Signed-off-by: Bart Van Assche Cc: Sagi Grimberg Cc: Christoph Hellwig Cc: Laurence Oberman Cc: # v4.4+ --- drivers/infiniband/ulp/srp/ib_srp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index e088a49..74e3ec8 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1330,8 +1330,13 @@ static int srp_map_finish_fr(struct srp_map_state *state, ib_update_fast_reg_key(desc->mr, rkey); n = ib_map_mr_sg(desc->mr, state->sg, sg_nents, 0, dev->mr_page_size); - if (unlikely(n < 0)) + if (unlikely(n < 0)) { + srp_fr_pool_put(ch->fr_pool, &desc, 1); + pr_debug("%s: ib_map_mr_sg(%d) returned %d.\n", + dev_name(&req->scmnd->device->sdev_gendev), sg_nents, + n); return n; + } req->reg_cqe.done = srp_reg_mr_err_done;