From patchwork Fri Apr 22 21:13:35 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: 8915641 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E0A4A9F372 for ; Fri, 22 Apr 2016 21:13:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5A48201EF for ; Fri, 22 Apr 2016 21:13:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5C81201CE for ; Fri, 22 Apr 2016 21:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751851AbcDVVNl (ORCPT ); Fri, 22 Apr 2016 17:13:41 -0400 Received: from mail-by2on0065.outbound.protection.outlook.com ([207.46.100.65]:13136 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751742AbcDVVNk (ORCPT ); Fri, 22 Apr 2016 17:13:40 -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=BTWhMhCEIkLdx30p1hD0BU11VxiXvsqCBxGvATrox2Y=; b=SxKFaJpCHX1/7LyA+d3PcmpKmV8FjLQ0VacRB1cSFm02KOUq/wlcvRDQVg8AKvALuW6YrI4Ad2ts0NG8kkN3eE6xN5KpVLxseQKgCrcVeZcUuwjAet2I3m1beEbl3le3drhKfzCnu6+nOAbvoILFdiun270dpoN8SPdmY/xKNk4= Received: from CY1PR0201CA0036.namprd02.prod.outlook.com (10.163.30.174) by SN1PR0201MB1872.namprd02.prod.outlook.com (10.163.76.144) with Microsoft SMTP Server (TLS) id 15.1.466.19; Fri, 22 Apr 2016 21:13:36 +0000 Received: from BY2FFO11FD037.protection.gbl (2a01:111:f400:7c0c::121) by CY1PR0201CA0036.outlook.office365.com (2a01:111:e400:58b9::46) with Microsoft SMTP Server (TLS) id 15.1.466.19 via Frontend Transport; Fri, 22 Apr 2016 21:13:36 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; lst.de; dkim=none (message not signed) header.d=none;lst.de; 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 BY2FFO11FD037.mail.protection.outlook.com (10.1.14.222) with Microsoft SMTP Server (TLS) id 15.1.472.8 via Frontend Transport; Fri, 22 Apr 2016 21:13:36 +0000 Received: from MILHUBIP03.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 41.67.03047.D939A175; Fri, 22 Apr 2016 14:11:58 -0700 (PDT) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.279.2; Fri, 22 Apr 2016 14:13:35 -0700 X-AuditID: ac160c69-5dfff70000000be7-96-571a939de371 Received: from exp-402881.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id E5.31.03935.FF39A175; Fri, 22 Apr 2016 14:13:35 -0700 (PDT) Subject: [PATCH 04/11] IB/srp: Fix srp_map_data() error paths To: Doug Ledford References: <571A936F.7040409@sandisk.com> CC: Christoph Hellwig , Sagi Grimberg , Laurence Oberman , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <571A93FF.8020102@sandisk.com> Date: Fri, 22 Apr 2016 14:13:35 -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: <571A936F.7040409@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrALMWRmVeSWpSXmKPExsWyRoxnke68yVLhBg/b2C1env/AarFy9VEm i2eHelkszn94xWSx7vV7FgdWj/P3NrJ47L7ZwObxft9VNo/Pm+QCWKK4bFJSczLLUov07RK4 MuZPmsNS0CxWsbmxg72B8bxgFyMHh4SAicSRQxpdjFwcQgJzmST2zlzGCOHsYJRofbKICaZo yiVWiPhSRom9B88DFXFyCAvYSmxuv8oOYosIqElserUIzBYS0JJYOvE3WAOzwGpGiS/LXjGB JNgEjCS+vZ/JAmLzAhU9PD8RLM4ioCqxdesZsLioQITE6nXXmCFqBCVOznwCFucU0JZ43jmf GeQgZgFNifW79EHCzALyEtvfzgErlxDYxCoxbZEkxA3qEieXzGeawCg8C8mkWQjds5B0L2Bk XsUolpuZU5ybnlpgaKpXnJiXklmcrZecn7uJERIPmTsY7z7xPsQowMGoxMP7oUEyXIg1say4 MvcQowQHs5II7+QJUuFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEed3ufQkTEkhPLEnNTk0tSC2C yTJxcEo1MNbt785ctMXk1Q+JN//lXrmmTlAN1gy/y+zcKn8nMS/+R7OngM48hoWxjlWZxZtW eX9h0dos+brq3nV/+3nnH9dLMEecfnuKYTVTct62f22B81ManEWuNP89FXNS93mFUOAkVsa/ 6pXFZvcTHs59qnhu6oeSxWvPrI7hWXJB+2rXw9cGesvfOSmxFGckGmoxFxUnAgCzCx12gwIA AA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJJMWRmVeSWpSXmKPExsXCtZEjRff/ZKlwg9OnZSxenv/AarFy9VEm i2eHelkszn94xWSx7vV7FgdWj/P3NrJ47L7ZwObxft9VNo/Pm+QCWKK4bFJSczLLUov07RK4 MuZPmsNS0CxWsbmxg72B8bxgFyMHh4SAicSUS6xdjFwcQgKLGSU+PlrL3MXIySEsYCuxuf0q O4gtIqAmsenVIjBbSEBLYunE32ANzAKrGSXu9f1iBEmwCRhJfHs/kwXE5gUqenh+IhOIzSKg KrF16xmwuKhAhMTqddeYIWoEJU7OfAIW5xTQlnjeOR8sziygLvFn3iUoW15i+9s5zBMY+WYh aZmFpGwWkrIFjMyrGMVyM3OKc9MzCwyN9IoT81Iyi7P1kvNzNzGCA5Mzagfj9YnmhxiZODil Ghi5Tu2e8vabTfoq1nTj5S8vm33h3HPp+5W5ukc8kqIFu36c8vU0Wb67x/zACqHjCQ39vJEz E4onVQht2Pt5ccnqUPdH3c1mqqXrtP+zByZuCH6ww/CoausGp+sGtoqRrvu+bf9372nshDir 3Upry6Sc71598LSo8Gtpp/e/DrtF/wX8j4r8jNmmxFKckWioxVxUnAgA4Xc/S/wBAAA= 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)(199003)(189002)(229853001)(65816999)(50986999)(59896002)(54356999)(76176999)(5003600100002)(87936001)(33656002)(11100500001)(19580395003)(80316001)(4326007)(2906002)(19580405001)(47776003)(5008740100001)(586003)(106466001)(86362001)(65956001)(65806001)(23676002)(1096002)(6806005)(1220700001)(77096005)(2950100001)(36756003)(4001350100001)(53416004)(50466002)(189998001)(92566002)(2270400002)(230700001)(81166005)(110136002)(64126003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0201MB1872; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD037; 1:DZpm0HMRPDnquJHcuriltfhGxBycsRykagzkVRN59zecXp4i2NsuSIZN6f8MFcDBtwxRxbj0+zriMOfNsr8rlYXX7dNMxcKnhZQvy52quBSFjh3SrAQBCawZz97lOiaUV8k7pxaYPTKUnk4z/9pO+Juc77dJxlzwl0GITDg/WnaozhPDiWD2jwSD1j1/8iiR3RGDTga68sdRQVUsk1C5KPseyuTw3hVpw2DE3ZNU+xZJkGGGJ4uuxoAZBhECfQlIaObiMdd1AyWi5x+tcCbKpNnKW/jVk7mmH2ygnmVbCzfenBIgHYzk/Uuao/l9DiU5bXVHXI0rv72r7FdNtUNOZEp1dFyl9kB2Qq20i2JGz86VbHbLQc7PBwgPttpjWMSgML+QcxhD7lUhlUtmbwfoROav0vV8tS07290osLPzzZeOb1AlygEwZevZKi7hHqQtj20EiO5L0BxQNnqMoWYoZKx6g0UBxgLEeBlV7Ljiumc= X-MS-Office365-Filtering-Correlation-Id: 2a0b5e53-9fb3-4d76-b2f2-08d36af2f7ce X-Microsoft-Exchange-Diagnostics: 1; SN1PR0201MB1872; 2:D29Ym/NG0bKrAQqNyNuW7YaKqlafteYsm00RiNjVrvxrxJhOUtO2pEjFDLQr5/HOgb3d1WbyEUo72TRU/EkL6DWtgNgBMf7634Ka+dMI5muvVGNWAtfHEtOkHVdp8AV1p3FgGE2q8m4tvV8K7jzmSR+WwKZxrgelhSKArBbDyanGnoMPpkVpUoymmoJVYlMW; 3:DHg0fMcNDBIf2R4Y1gh5SToQY3rZT3a6AEAPH4JovTiAveYnLbzCKB32q7BiA1nX9rEPAJ2xXUETv88JmAKue59FMoWeYNgtTuju6A1OC6Xtvp3IHMyai3OeZuRROScHd4RmHKagAYrZsP0N1Re1gE9t8DUSqNoCaBMkUSzmQChcEU+sz+vO8e8t116eb+2qalX/JqcxoZJk4OOSAx6JsJOFtSaxpoVjghYP0u1hRQgrealC7b95n1FsO3Sy8tqfhIr+eq591wje2GT7GN1cnA== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:SN1PR0201MB1872; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0201MB1872; 25:lCFjjjgto2mKcLfbqShIjIL5oBVvwJ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4Q8fDdiYiCzuoNgdyDkw7Qowk+5D+MCqST3wjk4/g28pq7SRql8Qoy6lgC4e+VEilxDqipwL0+WaRNLDqbNY3R8QWgTWJCo2N5UlMN5/V3ePmypkfgSB+jZ1KhYIcBnIkAZmWtd+o4P0XDHxMxvQ; 4:R45dcOFw+HtlIS4NNsGFDsH09MHu5VIXX4fgSrrOdsLCwADSCRnxCRFg4X80VJgEuEjTb/ERIXvIC1cJHFtW5I6PmxEu44MK+BcEOBPikGytkZcL3+N+apKIMxRCZGUeoSamGZyOPrAcZVs5w6kT4cYXMstvXRkORlxYBRlglfd5rLoy3EFeiTIFkvH6oQNPh9tvUdaJRVDUIdnxRrXK/KxvG8KCB3t//o41QapBA4OHkXl7ZxbZrI/Or/ys+Qd3aNwCjMIdTpoDTX6OaSSKOOv2JXd4K7TKTq7yLu0dWZG38MmZfB0pZ9nV6BvGNe+hQ+NDhQ/g9sQ0EJJqgzpTFdWZr4M1ZiWNZEU2TUt2l3yTTB7QX0l6MBmsXEiah62OhKKWWN37dyTDPeTIHGPErIQqhwvOFRuLG1oZ 3nx0Rgsvcgiihiw/NZJAv5dA3mlO X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(9101521026)(601004)(2401047)(8121501046)(13016025)(13018025)(5005006)(3002001)(10201501046); SRVR:SN1PR0201MB1872; BCL:0; PCL:0; RULEID:; SRVR:SN1PR0201MB1872; X-Forefront-PRVS: 0920602B08 X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtTTjFQUjAyMDFNQjE4NzI7MjM6Q1ptR3ZzWjh0WVBrTnYrQjRtMDMrS0cw?= =?utf-8?B?RjlkYUlZbHVvckt3QkxUOUdVK213UzI5U3ZaSkJmelZhdTJUTFNkYkE2L1lZ?= =?utf-8?B?YkJSSlFsOTk1YU8rSmxsL1hvK0d5UVZBSlNIN2JEWHpia0VuZEFCMVEyUFpi?= =?utf-8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sHTAQh2w4IYB7m5JHrsxM36kgOSZN9tzX0/Vhbh3OVX0e5GzVjUfvguc2RWAG0ozwABvV5nR1Ts/CG51VTR1DQBTioANGCLkzabEr2Hvy9OkU8cWzAIEWMZ3dzqBtY4s=; 20:cpAxuOYsD+QhW730pDGSaUXC/eUKkdSRCU8FSiacoY0Y5KW2khAbr5fpHeaAI6hIKB2ETV74OVwMPRuqaILW69qBlLC1p7LN5Kk0m+qjlkckuraEyvPOpJZ2x/Z5tWRU8nI9LyslyMfmW3XIuD+4QM4uYx0xIkFsZ0GfHpANv37R/zVlNVrO5H1fqUd3f8e1Z7IpcZ0ODStfSSXs5ZFFBt70dajOCwAiDLTDv05kBAObDn6CdTwwgun+tLihB7Q5 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2016 21:13:36.1052 (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: SN1PR0201MB1872 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.8 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 Ensure that req->nmdesc is set correctly in srp_map_sg() if mapping fails. Avoid that mapping failure causes a memory descriptor leak. Report srp_map_sg() failure to the caller. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: Laurence Oberman Reviewed-by: Sagi Grimberg Reviewed-by: Christoph Hellwig --- drivers/infiniband/ulp/srp/ib_srp.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 2f8ab5c..1354a09 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1428,8 +1428,6 @@ static int srp_map_sg_fmr(struct srp_map_state *state, struct srp_rdma_ch *ch, if (ret) return ret; - req->nmdesc = state->nmdesc; - return 0; } @@ -1454,8 +1452,6 @@ static int srp_map_sg_fr(struct srp_map_state *state, struct srp_rdma_ch *ch, state->sg = sg_next(state->sg); } - req->nmdesc = state->nmdesc; - return 0; } @@ -1475,8 +1471,6 @@ static int srp_map_sg_dma(struct srp_map_state *state, struct srp_rdma_ch *ch, target->global_mr->rkey); } - req->nmdesc = state->nmdesc; - return 0; } @@ -1610,11 +1604,14 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, memset(&state, 0, sizeof(state)); if (dev->use_fast_reg) - srp_map_sg_fr(&state, ch, req, scat, count); + ret = srp_map_sg_fr(&state, ch, req, scat, count); else if (dev->use_fmr) - srp_map_sg_fmr(&state, ch, req, scat, count); + ret = srp_map_sg_fmr(&state, ch, req, scat, count); else - srp_map_sg_dma(&state, ch, req, scat, count); + ret = srp_map_sg_dma(&state, ch, req, scat, count); + req->nmdesc = state.nmdesc; + if (ret < 0) + goto unmap; /* We've mapped the request, now pull as much of the indirect * descriptor table as we can into the command buffer. If this @@ -1637,7 +1634,8 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, !target->allow_ext_sg)) { shost_printk(KERN_ERR, target->scsi_host, "Could not fit S/G list into SRP_CMD\n"); - return -EIO; + ret = -EIO; + goto unmap; } count = min(state.ndesc, target->cmd_sg_cnt); @@ -1655,7 +1653,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, ret = srp_map_idb(ch, req, state.gen.next, state.gen.end, idb_len, &idb_rkey); if (ret < 0) - return ret; + goto unmap; req->nmdesc++; } else { idb_rkey = cpu_to_be32(target->global_mr->rkey); @@ -1681,6 +1679,10 @@ map_complete: cmd->buf_fmt = fmt; return len; + +unmap: + srp_unmap_data(scmnd, ch, req); + return ret; } /*