Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751649AbdICHUL (ORCPT ); Sun, 3 Sep 2017 03:20:11 -0400 Received: from mail-he1eur01on0069.outbound.protection.outlook.com ([104.47.0.69]:26048 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751224AbdICHUH (ORCPT ); Sun, 3 Sep 2017 03:20:07 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tariqt@mellanox.com; Subject: Re: [PATCH][next] net/mlx4_core: fix memory leaks on error exit path To: Colin King , Tariq Toukan , netdev@vger.kernel.org, linux-rdma@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20170831163053.2349-1-colin.king@canonical.com> From: Tariq Toukan Message-ID: <1e838306-09f4-b3dc-18e2-437a17f7c927@mellanox.com> Date: Sun, 3 Sep 2017 10:19:52 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170831163053.2349-1-colin.king@canonical.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: DB6PR0801CA0065.eurprd08.prod.outlook.com (2603:10a6:4:2b::33) To HE1PR05MB1803.eurprd05.prod.outlook.com (2a01:111:e400:7a28::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8dccc7a0-516d-4129-3de3-08d4f29c3202 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:HE1PR05MB1803; X-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W/zTw48VbucFjqVS/q77NndXgfMh+YiyOlq1vLfxu7Fknd7pU0I+NAnVzHtdT41x2so4sg38KWHq6bbRiFbaYvSjvI2AOB1X/gptOcBsUewblNBk7z436RLU5TBe7hepR+KtrC63++QlRbgNPWRicv6uJPBHilMm4DKxqBXOqbRpSdIktyUt25OsFiKnN+KPibi36z6qhzN95joHExKmpjq9SsvShKkcmHnY1GPv8aIR2Mbgz//GvbUYq3M/E27SjLVDA0AKI6EAdgkyVzfYD/+CgkCdOVNcMev99VUFsJNC1q6Q9JGI7lDnAf/+AHWFp/0pXVpc1pfylRNBoEC30aDv1NefMfyxtZjiZ5i9eTaw0ha6wRdD5IpJi42;4:CBYx4WIwSOTXHFW5PnVK1wixSNuf9cPOsUq0d4JPTOoC605PEx2mDqkAglhUuhsHbJaj+K9yOz9hSvRAEbRgYlTJm0V9d9Dxj8mIzGEaa9CWn1yKkCNXTG06fj3kqyi2JJroU5zT228Jj5Ec5a1G03Ly64Y0uPEpe7K+ugeld2oika3Xsng4WcxmGcHn4rGaEiEEuggxmY8KDTZvIGzEabQsarKkkv5elwLTx+7XyNEU07q4EIPPBXeB5T3/B5HQrXuF1nfCafsknaCY6I4dDHo+C2Ylvf3JlcETjH1zMHk= X-Exchange-Antispam-Report-Test: UriScan:(198206253151910); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:HE1PR05MB1803;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:HE1PR05MB1803; X-Forefront-PRVS: 041963B986 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(7370300001)(4630300001)(6049001)(6009001)(39860400002)(199003)(377454003)(189002)(24454002)(106356001)(23676002)(101416001)(76176999)(77096006)(50986999)(54356999)(6246003)(2906002)(105586002)(97736004)(7350300001)(36756003)(6486002)(25786009)(6116002)(3846002)(229853002)(83506001)(230700001)(4001350100001)(4326008)(478600001)(33646002)(86362001)(53546010)(8676002)(31686004)(47776003)(65806001)(66066001)(5660300001)(65956001)(50466002)(6666003)(31696002)(2950100002)(68736007)(305945005)(189998001)(42186005)(64126003)(81166006)(81156014)(7736002)(65826007)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR05MB1803;H:[10.8.2.253];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA1TUIxODAzOzIzOnlHcnQ0MGpHTFlackNWcGE4ZENRZWErNUFs?= =?utf-8?B?MS9vZFNpNzYyYmpNclN5TUpySEpHRUh3a3hLeUgxZi9qVjROWG5OSm9QTElY?= =?utf-8?B?Um1xYXIyOEg3NDFaL2J4NXRWbnpBUHJsRjdOSkI5b1MwYzY4TGgxdGRrcW53?= =?utf-8?B?QkV3dldTYWVXa0ZZVG40d2NaOVIrT0hZcXlzUTFjUDRnMCtaT0tXdkd4MFV5?= =?utf-8?B?REtJekdGOFhZSjlwMTIyY2VZc2xyeTYxLytwQkVLekNndktPUnRadDBxa2Nn?= =?utf-8?B?VkRDd05BL0d0Rkd2ak10NElhTENDbmludGtlbDl2bzJoWGxuUi9DY3YxcEVI?= =?utf-8?B?b2F0SW5OU3VOUmg2NnhtM3Q2UHA4MmZzZ21iUDNrUFZuQVFsdGFWTW9NbkNq?= =?utf-8?B?SGN4V0xUaEdhck1sWnlzbEFpQ0I1enJVSzRmYTgrUzY5YndYU090WkU1ZU9U?= =?utf-8?B?M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5Nlu9lAhhgQGVXP9f+ukBJhAUv/DuEc9X1eFpvsBZ/rFiRMb3zz4qt11zZXSJu5/hnZEWVjsloEq2A==;24:J+vbrK5jwGu6aADuWltaHNWFc6bGaRIDmeNL9RVyIjcbFSikOZVp8mIRhz7zzIu79Gj9grEzdfHJcbT4qjyenvI26v9kGw6LJutbvuLhV74=;7:DSfY/FW8lbV6Ob5bWiMxmYFMq2dzgg2lc9fJqWxlviWaG9w2XRzRmM54gHT4lWDNcdDg3qV/jdM6PWiGdcpnDPcTgTvvzODQ36gefLGzqIfO0PYnNcHwpcIbttiO+ktz+vBcColH0EXnVhjTF3aKbMlZi+aAML/CDsfm7qtuYQlvVPVdy5vshJZrTG1zjp5yhECp3mInFEMJCqc7N1W/Hh66UnynCkS324izO0D+nlE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2017 07:19:58.7971 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR05MB1803 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1267 Lines: 35 On 31/08/2017 7:30 PM, Colin King wrote: > From: Colin Ian King > > The structures hca_param and func_cap are not being kfree'd on an error > exit path causing two memory leaks. Fix this by jumping to the existing > free memory error exit path. > > Detected by CoverityScan, CID#1455219, CID#1455224 ("Resource Leak") > > Fixes: c73c8b1e47ca ("net/mlx4_core: Dynamically allocate structs at mlx4_slave_cap") > Signed-off-by: Colin Ian King > --- > drivers/net/ethernet/mellanox/mlx4/main.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c > index 1c92101b3ec2..d46f3283ec36 100644 > --- a/drivers/net/ethernet/mellanox/mlx4/main.c > +++ b/drivers/net/ethernet/mellanox/mlx4/main.c > @@ -977,7 +977,8 @@ static int mlx4_slave_cap(struct mlx4_dev *dev) > if (dev->caps.num_ports > MLX4_MAX_PORTS) { > mlx4_err(dev, "HCA has %d ports, but we only support %d, aborting\n", > dev->caps.num_ports, MLX4_MAX_PORTS); > - return -ENODEV; > + err = -ENODEV; > + goto free_mem; > } > > mlx4_replace_zero_macs(dev); > Acked-by: Tariq Toukan Thanks Colin!