From patchwork Mon Aug 3 17:04:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 6931631 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 9B48E9F38B for ; Mon, 3 Aug 2015 17:05:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 972D22039E for ; Mon, 3 Aug 2015 17:05:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA86520647 for ; Mon, 3 Aug 2015 17:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753866AbbHCRFU (ORCPT ); Mon, 3 Aug 2015 13:05:20 -0400 Received: from mail-bn1bon0079.outbound.protection.outlook.com ([157.56.111.79]:31712 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754568AbbHCRE1 (ORCPT ); Mon, 3 Aug 2015 13:04:27 -0400 Received: from BLUPR0201CA0004.namprd02.prod.outlook.com (10.163.116.14) by CY1PR02MB1261.namprd02.prod.outlook.com (10.163.16.154) with Microsoft SMTP Server (TLS) id 15.1.225.19; Mon, 3 Aug 2015 17:04:22 +0000 Received: from BY2FFO11OLC010.protection.gbl (2a01:111:f400:7c0c::124) by BLUPR0201CA0004.outlook.office365.com (2a01:111:e400:52e7::14) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Mon, 3 Aug 2015 17:04:21 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.173) smtp.mailfrom=sandisk.com; mellanox.com; dkim=none (message not signed) header.d=none; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.173 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.173; helo=milsmgep12.sandisk.com; Received: from milsmgep12.sandisk.com (63.163.107.173) by BY2FFO11OLC010.mail.protection.outlook.com (10.1.15.21) with Microsoft SMTP Server id 15.1.243.9 via Frontend Transport; Mon, 3 Aug 2015 17:04:18 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com ( [172.22.12.162]) by milsmgep12.sandisk.com (Symantec Messaging Gateway) with SMTP id 48.BA.06265.11F9FB55; Mon, 3 Aug 2015 10:04:17 -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.224.2; Mon, 3 Aug 2015 10:03:41 -0700 X-AuditID: ac160a69-f790f6d000001879-ed-55bf9f117423 Received: from [10.60.52.33] ( [10.177.8.100]) by milsmgip11.sandisk.com (Symantec Messaging Gateway) with SMTP id 7B.8D.03643.11F9FB55; Mon, 3 Aug 2015 10:04:17 -0700 (PDT) To: Doug Ledford CC: Eli Cohen , "linux-rdma@vger.kernel.org" From: Bart Van Assche Subject: [PATCH] IB/mlx4: Fix memory leaks related to updating GIDs Message-ID: <55BF9F11.6050708@sandisk.com> Date: Mon, 3 Aug 2015 10:04:17 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRmVeSWpSXmKPExsWyRoxnka7g/P2hBt8mWli8PP+B1eLbwQiL Z4d6WRyYPZ5NP8zk8X7fVTaPz5vkApijuGxSUnMyy1KL9O0SuDLWv/rJUrBPpOLb3z1MDYy/ BboYOTkkBEwk3tx4ywZhi0lcuLceyObiEBI4wSixddcqVghnO6NE385fzDAdj6YdYIRIbGKU mP/gHBNIQkRATWLTq0XsIDazQKzE+c/NYHE2ASOJb+9nsoDYwgLOEgf7O8B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xFxUnAgAZQUNe4AEAAA== X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC010; 1:r5UUdhkQ1h3BvDG/ZHYZArqA76DpiF7a1GM96/GsS2nsu3yqOxaG6iPnj7darRVfE2iTLkjK9l84QIA+4yli6de591R0BuIhNG5XCVxFQ5yTO4mg1s3BYaQ1WTBBNeWQNwmSZPj77rIJzuKr/SOiuNgLllvXfFR3ES8hm6Z991YF7zfKWTPOB+yqRueQRFwjtR1sEWf0yCEmHYZOsmoKCEpCdam48GSdhxfmWTnzHWQT6UzMbk88S1LQm1eGoUD3cYpE7n52JM/BO404770jZo2HiFHoy8w+L3cogDtfV8XUBOn+wX+C8242E4NmLE9C55nV7UoF9QlfzVVldrFbgg== X-Forefront-Antispam-Report: CIP:63.163.107.173; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(189998001)(68736005)(19580405001)(62966003)(50986999)(33656002)(47776003)(64126003)(64706001)(229853001)(92566002)(4001540100001)(81156007)(50466002)(4001350100001)(36756003)(54356999)(65806001)(5001960100002)(77156002)(5001860100001)(77096005)(5001830100001)(59896002)(65956001)(110136002)(97736004)(46102003)(86362001)(80316001)(87266999)(19580395003)(87936001)(65816999)(23676002)(106466001)(69596002)(83506001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR02MB1261; H:milsmgep12.sandisk.com; FPR:; SPF:Pass; PTR:ErrorRetry; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR02MB1261; 2:LhMbnAyK4DlDtuCk6pRt7JbFBU5bpemqLqSgAmdKcuijZ3B2FsGTjbaW6zH6U2gD6r+tMU1RjRhHDpv6k9GVSwUoxM38DDc9C9sxWvZLfxYPksmvxJ+1BOPRBzLXv90ZLgqq/iBzCUjebU2/Kr6jsgKrM/7xX8reFgQI5BBdZYk=; 3:kGUKUnljeE+yYmaeNiGKi/V3DC347F7ltMWsV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z0xSz66xBKtL+Vba5sSj; 4:5Bi8khk9h3+rzapvL4VcBI+swlf2vSReGgDvwsxfpcmnaYiTkL57RSrHk3n1ohj0eTuq03ufFSwhehfb7vCJMzqejolJk9qrBKjoCcRVXNEnutsUvoAGHxlYIUUh+ggG+wSKim4q+hwb97oxzfGowCh1tLCgNdRnJWyg12trFEkaLFDjiH2zV2Hpfh8S+auioiAc601Zid5/x/eU+qe84IMGQP2jE9Y+7/gDWF2q3G9Aslor9ZRYW2EkCb3WsLzs9uLNdXi2VNM7dJmMFmEm36146TaXCF6VwzyrtG43nLg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:CY1PR02MB1261; BCL:0; PCL:0; RULEID:; SRVR:CY1PR02MB1261; X-Forefront-PRVS: 0657D528EC X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTFQUjAyTUIxMjYxOzIzOkxWdE4rVXRIWmNtcDliUmkveG5neUZPSTRm?= =?utf-8?B?cFNtbitEL0lxMDROT0NXMkRaaWZzWlQzS2prMi93dGk3dEtEZDFoMFdWbGhs?= =?utf-8?B?K1RDNUZ4V0kvZnpPVVQxOUVTT29sNzNwRmI0N0dvWUt1VTlTZ3RCb2Vaemlh?= =?utf-8?B?TTUrdXk2K1NlRjFBRzIwQTMwM0pNWlpERFdjSzBaT1VEY3NCelN5MVBNVFBu?= =?utf-8?B?dzlWMkZWaUxFbkRDcWRRN1FLUHIySlo5bkhWeWVIaVJUY0QwM1dvTEVRY2Zz?= =?utf-8?B?blZtcGUrZzVlS0JJVmh4cXZxbFMrckthMGREenBnR21jYUxwczNRTEVWYTFN?= =?utf-8?B?eGgzalgvTHFZeXhobUJRTUQvTUV4TEkyMlpVWk5KZzVlNkhsdU9TNGE4aVJj?= =?utf-8?B?cktneGhwc3E2WWhyV3NOVnYrOTVGeENJRnBIVC9Xc01mWlY1T1kv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cvYU9QUDd2TGIrMFRXQ1NlR2dBLzVQ?= =?utf-8?B?RGdrTEo2VWFCc2pEZy9EbHlqZkorYVVWNjJ0RXMyL1ZJbG9kMjJoaGI1ZVpS?= =?utf-8?B?WHVSRmdRQmo2Y08wclRwYTRJYWxwRE1nUXI1S0NHQ3czY1JRUUlHczhvZTVl?= =?utf-8?Q?Evh+giOMQy9nToiz2EA99TxB8uSYk/AVNs+Z20sGPCBQPa?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR02MB1261; 5:hinsSlvMXSCHhO1ozXkpWLY6s5iRDx/7Vd4mpikzxAkJzkhGDrvaDU/CZc2heDzNIdDId6A/XMYRQgV0lMNMQixwgSgctJJORqQAUFV+Z99781PRJabib/2aCskXHwEUqbqqAt9XqNEfLt+bPQg1zw==; 24:NRp+WB03DI04PS/Xf+++qeK924NCweP93U0Pr0E7UIXg6xOd7UdO3ErMqRqhH/dTWDbtxIuvjSYbIO7y8IeE4FZWzDBkCTZZnnxNUm5kN8U=; 20:l5lNmlKNEJzSMgt1PBPdpMe9AUqKBxxv5f80Vocqdhvuro/okFmKyYGGqs21A7oGNQVKpHMgqjX2Uoojt7wQ5zAPEOZR8kXA5E42JB9Cnrf1taYUqBjOFdttLnT1Zs8oGf6dbo5+K8A9M0Zi5AfwuliI7cqEnOp92hClIvo02LU= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2015 17:04:18.5275 (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.173]; Helo=[milsmgep12.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR02MB1261 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.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Fix the memory leaks in update_gids_task() and reset_gids_task(). kmemleak reported one of these leaks as follows: unreferenced object 0xffff88044576d668 (size 4096): comm "softirq", pid 0, jiffies 4294942043 (age 976.560s) hex dump (first 32 bytes): 00 02 00 00 00 00 00 00 70 d6 76 45 04 88 ff ff ........p.vE.... 70 d6 76 45 04 88 ff ff 60 d6 2d a0 ff ff ff ff p.vE....`.-..... backtrace: [] kmemleak_alloc+0x4e/0xb0 [] kmem_cache_alloc_trace+0xc8/0x2d0 [] reset_gid_table+0x2e/0xe0 [mlx4_ib] [] mlx4_ib_netdev_event+0x449/0x450 [mlx4_ib] [] register_netdevice_notifier+0x8a/0x1c0 [] mlx4_ib_add+0x106b/0x1140 [mlx4_ib] [] mlx4_add_device+0x41/0xa0 [mlx4_core] [] mlx4_register_interface+0x8c/0xf0 [mlx4_core] [] ext4_has_free_clusters+0x6/0x170 [ext4] [] do_one_initcall+0xad/0x1e0 [] do_init_module+0x61/0x1ec [] load_module+0x1d42/0x26b0 [] SyS_finit_module+0x80/0xb0 [] entry_SYSCALL_64_fastpath+0x16/0x7a [] 0xffffffffffffffff Fixes: fa417f7b520e ("IB/mlx4: Add support for IBoE") Signed-off-by: Bart Van Assche Cc: Eli Cohen Cc: stable@vger.kernel.org # v2.6.37 --- drivers/infiniband/hw/mlx4/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 8d88760..d79346e 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -1572,12 +1572,12 @@ static void update_gids_task(struct work_struct *work) int is_bonded = mlx4_is_bonded(dev); if (!gw->dev->ib_active) - return; + goto free; mailbox = mlx4_alloc_cmd_mailbox(dev); if (IS_ERR(mailbox)) { pr_warn("update gid table failed %ld\n", PTR_ERR(mailbox)); - return; + goto free; } gids = mailbox->buf; @@ -1595,6 +1595,8 @@ static void update_gids_task(struct work_struct *work) IB_EVENT_GID_CHANGE); mlx4_free_cmd_mailbox(dev, mailbox); + +free: kfree(gw); } @@ -1608,7 +1610,7 @@ static void reset_gids_task(struct work_struct *work) struct mlx4_dev *dev = gw->dev->dev; if (!gw->dev->ib_active) - return; + goto free; mailbox = mlx4_alloc_cmd_mailbox(dev); if (IS_ERR(mailbox)) {