From patchwork Fri Jun 10 18:08:25 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: 9170215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 23E5E6048C for ; Fri, 10 Jun 2016 18:08:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AF8C281F9 for ; Fri, 10 Jun 2016 18:08:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FB632833F; Fri, 10 Jun 2016 18:08:41 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 42E392824F for ; Fri, 10 Jun 2016 18:08:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752270AbcFJSIh (ORCPT ); Fri, 10 Jun 2016 14:08:37 -0400 Received: from mail-bl2on0088.outbound.protection.outlook.com ([65.55.169.88]:52875 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751382AbcFJSId (ORCPT ); Fri, 10 Jun 2016 14:08:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandiskcorp.onmicrosoft.com; s=selector1-sandisk-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=8Q5woky/QLtHCeWcSInNIGhSugKgti8IymAgUtD9rak=; b=jX0O7Zrvp6/bG3G13BfcMSgPXFXomSJFVbydSj0MoWmMR7616V0gt+q5ww81O9jUljhGNwHhIMUiXPq7V8apo1mSlQ9A9IfxpK46aO1bQq7l+EAqywm/N9W7gTlgqwNE9ZlwFaPGo+jbC2KVTn1puxxuX+CeQ8gQtxMbaq1rTv8= Received: from BY2PR02CA0027.namprd02.prod.outlook.com (10.141.216.17) by BY2PR02MB523.namprd02.prod.outlook.com (10.141.139.27) with Microsoft SMTP Server (TLS) id 15.1.506.9; Fri, 10 Jun 2016 18:08:29 +0000 Received: from BY2FFO11FD045.protection.gbl (2a01:111:f400:7c0c::197) by BY2PR02CA0027.outlook.office365.com (2a01:111:e400:2c40::17) with Microsoft SMTP Server (TLS) id 15.1.501.7 via Frontend Transport; Fri, 10 Jun 2016 18:08:29 +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 BY2FFO11FD045.mail.protection.outlook.com (10.1.15.177) with Microsoft SMTP Server (TLS) id 15.1.497.8 via Frontend Transport; Fri, 10 Jun 2016 18:08:28 +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 D5.BC.03023.9010B575; Fri, 10 Jun 2016 11:03:54 -0700 (PDT) Received: from milsmgip11.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, 10 Jun 2016 11:08:26 -0700 X-AuditID: ac160c69-6db3098000000bcf-3d-575b010aab51 Received: from exp-402881.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 4D.C4.02607.9120B575; Fri, 10 Jun 2016 11:08:26 -0700 (PDT) To: Doug Ledford CC: Sean Hefty , Steve Wise , Leon Romanovsky , "linux-rdma@vger.kernel.org" From: Bart Van Assche Subject: [PATCH] IB/cma: Make the code easier to verify Message-ID: <25a76a5c-dc56-3a75-cdf8-096f89b8e2df@sandisk.com> Date: Fri, 10 Jun 2016 11:08:25 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRmVeSWpSXmKPExsWyRoxnkS4XY3S4wd8DUhYvz39gtTg0/Q+r xbNDvSwWzes3sFj8W9vN4sDqsXjPSyaPnunZHo+en2P0eL/vKpvH501yAaxRXDYpqTmZZalF +nYJXBlta08yFizQq1g1dQ57A+M2tS5GTg4JAROJzdfusXYxcnEICcxlkmj9284I4exglJi4 cwYLTNXeKYvYIRJLGSU2LT3PBJIQEVCT2PQKIsEssI5R4vrSp8wgCTYBI4lv72eCdQsLmEs8 //KCDcTmFbCTmHbwJTuIzSKgKrF/0WOwQaICERK9v5awQNQISpyc+QTI5gAaqimxfpc+SJhZ QF5i+9s5zCC7JATmsUqs2TwVbI6QgLrEySXzmSYwCs5C0j4LoX0WkvYFjMyrGMVyM3OKc9NT CwxN9YoT81Iyi7P1kvNzNzFCgj1zB+PdJ96HGAU4GJV4eCN2RYYLsSaWFVfmHmKU4GBWEuHV /B8VLsSbklhZlVqUH19UmpNafIhRmoNFSZzX7d6XMCGB9MSS1OzU1ILUIpgsEwenVAPjXp2A NyvVXOZyugc/n/zpR6+ZjFn0oVffDzVMLV/wL67qwPSwQ43BB7k2yVZ/1Nguu8Ys8FnyRN4D nFMVDtqnvv73uWDJS7efSesuOZZs01hRLymz9Ymqwfqp1yzyOha25j3QLPg/I2snn0Vm6T/t pJZz1YXzymqPSZ/OTZ7LPin+vru0imSLEktxRqKhFnNRcSIAI3Lb43ICAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGJMWRmVeSWpSXmKPExsXCtZEjRVeKKTrc4NtUNouX5z+wWhya/ofV 4tmhXhaL5vUbWCz+re1mcWD1WLznJZNHz/Rsj0fPzzF6vN93lc3j8ya5ANYoLpuU1JzMstQi fbsEroy2tScZCxboVayaOoe9gXGbWhcjJ4eEgInE3imL2LsYuTiEBBYzSrydOZsZJCEioCax 6RVEgllgHaPEvL8vGEESbAJGEt/ez2QBsYUFzCWef3nBBmLzCthJTDv4kh3EZhFQldi/6DET iC0qECHR+2sJC0SNoMTJmU/AbGYBdYk/8y4xQ9jyEtvfzmGewMgzC0nZLCRls5CULWBkXsUo lpuZU5ybnllgaKhXnJiXklmcrZecn7uJERxynJE7GJ9OND/EyMTBKdXA+PDk/cxtOWzX2945 8UbZTPK5vK2j9OT5/DOnxCqbZ5rOvmjHJnp3vf7kvOX9nR7/BVdMKLrRe+xpKKfqjEd5ARsV kmcfM/Z537+nSSKeM/R2way0Z/v98gTjlx+O6nqZcZdD5mCm/CWzs6s/TfwknvI0cOZN2Xfn bqxo+yu4kT1k3o0fpTIPtJVYijMSDbWYi4oTAbVhbmrpAQAA X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(199003)(189002)(110136002)(77096005)(2906002)(189998001)(229853001)(86362001)(8936002)(586003)(106466001)(5008740100001)(92566002)(5003600100002)(575784001)(6806005)(50986999)(54356999)(23676002)(87936001)(356003)(65806001)(33646002)(68736007)(65956001)(64126003)(47776003)(31696002)(81166006)(2270400002)(8676002)(11100500001)(53416004)(4326007)(230700001)(4001350100001)(36756003)(19580395003)(81156014)(31686004)(83506001)(50466002)(97736004)(19580405001)(69596002)(65826006); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR02MB523; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD045; 1:YPL1DhOwvKJJvQTruWe2aInoq42mfOXAPmPKjnNCfiwMPd9oTraZY0xDm/pD8UjK9AvBEzCY3wVXvXjdn234/ncMtZeuZauiglwi739i7y2t8tffJ++DCRz4QDN6Hd1l0HNtmC33rrn6GrQ+GUdqBBbN8AFszIQD/vRNUucrPUDTo3Eyoo6kxsRlcaxc8WvqDs/aZwMDUGElwDtjkczU4vCRINTUnZzts3Q9xMfzNfZQsEXmE9LYpfZ1Prb52HLhXMchEVVUkOwWM7oD4kDp+jeDpLxruMq/e61s4dOHy0/rkOO8okkmZeaNH44gPg9YdtrjVOtWgvSTTZGC46Gbs/SsxzWcFc1y16NFyq08lNJXzJkp/jlxAvh2EBr2rKUDPUOzNXEm4citiXa1LgNdRAfZCDnZ7aGAW73ps73H5kh0tt0TudyBF79WP57S5UQEAqNns+nwYo2FJZ4iOddbxidmIbC1Aet72MaL1HMRDPU= X-MS-Office365-Filtering-Correlation-Id: 35083514-addf-4e13-3d8d-08d3915a399f X-Microsoft-Exchange-Diagnostics: 1; BY2PR02MB523; 2:4GY/qxlAdsNfNyw7MLii69itrBnhzkamqx4xcuXeH7Fd3GSvKDLSy8p0iY51+F6dD1bbyPCZr7ceHlpIxcyZuuQyWWBX7MGOApha4L8UbmV1qEFpMD40JjiNmw8y6HXptYswM90QslZS6I555YRQne7NfRSNdGZavTS3sB1O8pZ9Z9u0ih4w+d1q+42Xctm/; 3:gfo44rslnS+Y1oQ0Jw8tc6tdHTBVgKwSH7tI+RkRiWOdxve4AcygU0gdbOWBXsZhlWtsQoqf01q8wUobs2WebO7oBWn20d4jTr1gEwqMtawWEDo+hTfGROxkpVD7TxsZeyC6Yb32caYCYtPw64Vx/PhYwzFFJXNKXO6T32OzQuMugq4L1ZqSV3+fSKzW1MQVAuGQHyJHRZ3+VanR/y605ZAJISKiVonpPmGJ646EH3Rns+b4hoAbbGIHPk1Pi1+1Q3CikRBFLQoehaf5UWewNg== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:BY2PR02MB523; X-Microsoft-Exchange-Diagnostics: 1; BY2PR02MB523; 25:c4DqWDBX9TBQEAw0VZVn5SToZbgpMwoGfLh+bKWLpqobmybHYsDr7aSYP80BcOJQSDzO9Yi2HeX2oqux+4wmakGKZiID64KEy5sjykWQ+yxu4eUe+HRuaPeYTTsD66K869bZ3wP+DmIlgMeK/6iQde/v3/dcXfzZ22sVoKIBxaBKzFyx4C+d++QgDAi9bE0v7aqDfzuYQvssiqBriCIo9pX6a6VNtUhs4JWoFJrWOluhm7FL/lSYAeZ4nTCp6YO0nQyS8bINylBSzURh1LJUNQSKcpcWQsfGfAmBXSw2wOsz88qjW8I+T6dLjq9anNCBcKFgCiTF+7lycM/VhfVKKJouxOwQ58V+m7OK2UVFs/6zKiJhnS9PGSJUbOCZae2bkNNJ0t8GtnYnavQ2C8QlQWh+Z65fXnDLLIq04+jOzeiInZAw/62chYKYuWoCmoGk3Re+Z5XUuuPcF9lqrompx2/lDC76OYh9ti4BflpPTSFEdnzVnYA+eYf1MdJbZ5QCD42u/bvsEtV9OuK9ee37/q6AUfixeD+DhKN2npymZ0yoqpx2GaiHisBYqJIatFzTM3IWW/bJfMP5Dem7//MFPTmtJ1mnIawAEDQxpOD6kKkfX9QHDu6dndJec0cu8B92UzfDVz8RD8sjfaN2Ejk+B8qYEiew1rJupgnggVkIXmgpiOkdteGzCNWrdmp2+hkgG5/W/UGaEAHb6RmCeSJJ2xIHC23xibkpPSEcyK6+ly8z+QQU9CmI6OjvwwprZn5Xfc2iiFZrFmU3RC4JYGFo+cENTvK8hshC2M91JAuNsVo6WDyD3xwzZXq8L08o+e8Y X-Microsoft-Exchange-Diagnostics: 1; BY2PR02MB523; 20:7Ypp/XUI7wt1r2RM0HK+HbHeFplKm7bEWq9FECA+tOO4lQESU+RZnMBR9Lkpz0u5Mmj6jDmJ69xHG/Pbsi8C5CealT8sgqJ6Tw0FpnAIipIW/txl+7NNrjPVKGpCO3P8Sp4NkfZEtrpwCudL+/aLgStgJ2TogV7SBIbdajhysV9RFQqViEPzFX/2PK7TTBYoYDLXRqx6+RqXUwPGGE06MBK3yoku0KBFerFejoT/cOwCaDPqaEFGGlIfyhUhVzIw5ECR/CSJFXAo7rFRuHQ5MWFWtKCAFn34RInS2po4My5lj3cZkscms9a9irLuc0dMu+K5hJvTcpNbya/iVjC0WM5w3M5cIJpFEvH0M8SDlhzDDpiHPTNAPPPVZcX6U9b0Eiwl+MKfuogkBX/q8FA6NkUx2AYqalNs5C15mTpIvMp8+e+4qiyCKw8OGxWW5wMasS5VOj+7XEWq5YfzV9Mu9hwM24MOAX+VrG3HAzqDZrkyjCcXoy3XvefDPw4C9Z8H X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506)(42932892334569)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(13018025)(13016025)(3002001)(10201501046)(6055026); SRVR:BY2PR02MB523; BCL:0; PCL:0; RULEID:; SRVR:BY2PR02MB523; X-Microsoft-Exchange-Diagnostics: 1; BY2PR02MB523; 4:+rD0EypvI986+t5cAgLwhEOb432fuoqErG4hrpfx7xkMxtLkwa3m+MZW8Pg/AAKKrE0oacdJtIpDk8DzdruNZ4cBMBULlwMW3Vlf6Vozw4c71h0O3oEIthSEXHMPMxQfbioITWm42/nYgN9BtqTtteOl9otdFHfSPv9nh5pquUmQtMd9dP++dx1SApSUOjMCxbsAc5LF3cV/WjhRIxW7aPPN14NQjjieVMdGLK4YcrrETF/WEvQzo5WRJnecYeOIIwAfPFqX9bvl3CivXNPr9lxH0tsXv1+2etTjwWy36ncjvYgTfOZvAXTK8IEPYDrNBVt6xtotQipUxYLv1G1P+xjkXYUkh/SZ66AtmbnzAbvIS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ZPdzUzY3JLTzZnY01STXU0dVpVb3o2dXJVVTB1ZUpDUFIrczB2WFBl?= =?utf-8?B?MVc2VXNLZzliT1JEOG5wV0tEbENLeW9PNWR0ZGk3cmg0aFpKT0JrN3dWZUF6?= =?utf-8?Q?XPoTnaExyE2XZAVzl2SVjfaOU4O9urvGwSOFvb?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR02MB523; 5:17kK0W4Fwm2aHKOkdi/PTh5hWpW6b80osEqvrk98UoGh0lNpGsBBFw2xIP7/RWhnkwVfgAIEEa2Esf2YE2Vp9B5oqBMjzESmW2Vna7bsRN+KXWUkpXstxue9CuAdNcGhWVZX0WZ6wftTlZw97ceDVQ==; 24:uvaMd9JFEON0T7nUTLLj/qBi4bhAnFck6FopJUwSqRXi59nMy4irmsB2E8zMVQtiWhCgMe+swp7JezmbBTceKZ79pjZyhGtOKL/KyO8c1GU=; 7:tU8KduLUTL+xDVZqShqZZ42dTopTp0/W3qWX0X7UIJTXQeqaLzhfoHS/IUKj4ileGzfLDSd2rcnKkd4KC9iFaZSfzQUrL52QZa76a3g+mG/OxXcaAzjeG8PJeTJ5tzfN8a1V2GfUqSiQ99Rrww5aAJm/mWSN2+SqTFaWnSgkUHVYY+ROQoXMV/A8rkeH61T/4MpKb96qFqtS1yFyhUNiGw==; 20:fxhh5FqSsOmqD2lJe9RU1ht7Oq1wZBq5N+OT/lFvNll+p8b4d+beCmB9ri9uqUsV6LJ3zrqooHVGjssqUtS7JYNo8gHKnYJR2lnWizEvD7Aaq59LmyPxvJh6KZZ/0KwU9kMfdYrLrbM/vSM0JjySADjl3PvzXh+Re9CAYP6nTa+RGrsPUdk2FIB7ottNoVwr3SEaX6kIbZFG8VIUm3pIEObrQF3N2nf8s0oxTyhonVKEua2GV7lI9JpKM+OlHa28 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2016 18:08:28.8725 (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: BY2PR02MB523 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Static source code analysis tools like smatch cannot handle functions that lock or not lock a mutex depending on the value of the arguments. Hence inline the function cma_disable_callback(). Additionally, this patch realizes a small performance optimization by reducing the number of mutex_lock() and mutex_unlock() calls in the modified functions. With this patch applied smatch no longer complains about source file cma.c. Without this patch smatch reports the following for this source file: drivers/infiniband/core/cma.c:1959: cma_req_handler() warn: inconsistent returns 'mutex:&listen_id->handler_mutex'. Locked on: line 1880 line 1959 Unlocked on: line 1941 drivers/infiniband/core/cma.c:2112: iw_conn_req_handler() warn: inconsistent returns 'mutex:&listen_id->handler_mutex'. Locked on: line 2048 Unlocked on: line 2112 Signed-off-by: Bart Van Assche Cc: Sean Hefty Cc: Steve Wise Cc: Leon Romanovsky Acked-by: Sean Hefty Reviewed-by: Steve Wise Reviewed-by: Leon Romanovsky --- drivers/infiniband/core/cma.c | 54 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index f0c91ba..c58ee77 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -708,17 +708,6 @@ static void cma_deref_id(struct rdma_id_private *id_priv) complete(&id_priv->comp); } -static int cma_disable_callback(struct rdma_id_private *id_priv, - enum rdma_cm_state state) -{ - mutex_lock(&id_priv->handler_mutex); - if (id_priv->state != state) { - mutex_unlock(&id_priv->handler_mutex); - return -EINVAL; - } - return 0; -} - struct rdma_cm_id *rdma_create_id(struct net *net, rdma_cm_event_handler event_handler, void *context, enum rdma_port_space ps, @@ -1671,11 +1660,12 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) struct rdma_cm_event event; int ret = 0; + mutex_lock(&id_priv->handler_mutex); if ((ib_event->event != IB_CM_TIMEWAIT_EXIT && - cma_disable_callback(id_priv, RDMA_CM_CONNECT)) || + id_priv->state != RDMA_CM_CONNECT) || (ib_event->event == IB_CM_TIMEWAIT_EXIT && - cma_disable_callback(id_priv, RDMA_CM_DISCONNECT))) - return 0; + id_priv->state != RDMA_CM_DISCONNECT)) + goto out; memset(&event, 0, sizeof event); switch (ib_event->event) { @@ -1870,7 +1860,7 @@ static int cma_check_req_qp_type(struct rdma_cm_id *id, struct ib_cm_event *ib_e static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) { - struct rdma_id_private *listen_id, *conn_id; + struct rdma_id_private *listen_id, *conn_id = NULL; struct rdma_cm_event event; struct net_device *net_dev; int offset, ret; @@ -1884,9 +1874,10 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) goto net_dev_put; } - if (cma_disable_callback(listen_id, RDMA_CM_LISTEN)) { + mutex_lock(&listen_id->handler_mutex); + if (listen_id->state != RDMA_CM_LISTEN) { ret = -ECONNABORTED; - goto net_dev_put; + goto err1; } memset(&event, 0, sizeof event); @@ -1976,8 +1967,9 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event) struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr; struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr; - if (cma_disable_callback(id_priv, RDMA_CM_CONNECT)) - return 0; + mutex_lock(&id_priv->handler_mutex); + if (id_priv->state != RDMA_CM_CONNECT) + goto out; memset(&event, 0, sizeof event); switch (iw_event->event) { @@ -2029,6 +2021,7 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event) return ret; } +out: mutex_unlock(&id_priv->handler_mutex); return ret; } @@ -2039,13 +2032,15 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id, struct rdma_cm_id *new_cm_id; struct rdma_id_private *listen_id, *conn_id; struct rdma_cm_event event; - int ret; + int ret = -ECONNABORTED; struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr; struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr; listen_id = cm_id->context; - if (cma_disable_callback(listen_id, RDMA_CM_LISTEN)) - return -ECONNABORTED; + + mutex_lock(&listen_id->handler_mutex); + if (listen_id->state != RDMA_CM_LISTEN) + goto out; /* Create a new RDMA id for the new IW CM ID */ new_cm_id = rdma_create_id(listen_id->id.route.addr.dev_addr.net, @@ -3216,8 +3211,9 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id, struct ib_cm_sidr_rep_event_param *rep = &ib_event->param.sidr_rep_rcvd; int ret = 0; - if (cma_disable_callback(id_priv, RDMA_CM_CONNECT)) - return 0; + mutex_lock(&id_priv->handler_mutex); + if (id_priv->state != RDMA_CM_CONNECT) + goto out; memset(&event, 0, sizeof event); switch (ib_event->event) { @@ -3673,12 +3669,13 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast) struct rdma_id_private *id_priv; struct cma_multicast *mc = multicast->context; struct rdma_cm_event event; - int ret; + int ret = 0; id_priv = mc->id_priv; - if (cma_disable_callback(id_priv, RDMA_CM_ADDR_BOUND) && - cma_disable_callback(id_priv, RDMA_CM_ADDR_RESOLVED)) - return 0; + mutex_lock(&id_priv->handler_mutex); + if (id_priv->state != RDMA_CM_ADDR_BOUND && + id_priv->state != RDMA_CM_ADDR_RESOLVED) + goto out; if (!status) status = cma_set_qkey(id_priv, be32_to_cpu(multicast->rec.qkey)); @@ -3720,6 +3717,7 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast) return 0; } +out: mutex_unlock(&id_priv->handler_mutex); return 0; }