Received: by 10.192.165.148 with SMTP id m20csp640767imm; Wed, 2 May 2018 06:32:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoLj6mqDMH4YKqFuS8ePASoVdX1fX/8i19zA6aeiyucAmg+oEBYl4S/Aezo9cDUEURd7HuK X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr20161434pla.205.1525267927056; Wed, 02 May 2018 06:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525267927; cv=none; d=google.com; s=arc-20160816; b=OaE1o/V2iHCSzvr+vzRhGIDjY4Oc75MwRvSwnvTdcE/b1H4TA5BXR1e0qivPqHk5WX gEO6IIupdruFOYPbQrUnMKJwKqgjSwBQvYkgAmycwqZryaRDiNPQXPdHdI2djbIOiinD UA44I73ErR5AGY01uthnWzlD3wdXSl2Ojxttpq6IvEk6WNopKOLTT+RuKMAsgnlhxJlz u/04HuIPhxNRWnubWa/imWmw3cvLveoR5D6iwWF2Q9ybhFCXi9pagatqyvCr7ud6OniC a3eggomqgvP+h/thFNDSOQe6q88MogmWGWFoXMKrFOH2FmHPcw4/x3v2yWxPl54QVSo8 Mjvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature:arc-authentication-results; bh=fboM5tXXkjEQZvEKOpULskzO2B0+Kzatx3ECXdNCvEc=; b=IUJKYXTakTlVgFnWQ488n7QsNkQ2DKzHyPpVgh6lDgBkqroqh8Ahkyqy7RSlnAG4L9 vlnxksx8doTTRxRTuMxf8UJVTgpl2Fm07OHX1rdprj/akTIyamv5jRCCI23Cnr7F9vLZ 5NwiCiQt2yISdc6Yi3BIlwbQYf8SMOpFqNj2Uc1P3WtEVmgS+xPbz641/qVONaHMmRrE i481QHBPfJP7d0QR6M6+6kBqpnrmtAhaizpMNGsjId8Ocp77e6vKRS0EKVHZjEK1jT8U efgbnOi6ewE97kbAqgKibVkS+Nro6b3D436X+aAXbG3xQqEY2MfeUxh+5ES9wVad1VI2 eSgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=OrYvavgy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10-v6si9184627pgo.58.2018.05.02.06.31.44; Wed, 02 May 2018 06:32:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=OrYvavgy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751525AbeEBNbh (ORCPT + 99 others); Wed, 2 May 2018 09:31:37 -0400 Received: from mail-db5eur01on0049.outbound.protection.outlook.com ([104.47.2.49]:48496 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751121AbeEBNbe (ORCPT ); Wed, 2 May 2018 09:31:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=fboM5tXXkjEQZvEKOpULskzO2B0+Kzatx3ECXdNCvEc=; b=OrYvavgyh7RWmAeEiI8AdnpdWPO3DsoNW6ar9apMEJKKcP5zEE0FtqbkZZz12X7oB4GMfkh34ysk/W1JIfa++WRqbK9AJkzLf1UxDkO2zPSjTwkPNp3VwvCY7552/IaMkXjMUC8bmPLO+HKd01tqruhb5NDu+7UZwElMKdC52rE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tariqt@mellanox.com; Received: from [10.8.1.14] (193.47.165.251) by DB6PR05MB3254.eurprd05.prod.outlook.com (2603:10a6:6:1b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.18; Wed, 2 May 2018 13:31:30 +0000 Subject: Re: [PATCH] net/mlx4_core: Fix error handling in mlx4_init_port_info. To: Tarick Bedeir , tariqt@mellanox.com, gthelen@google.com, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180427152015.185861-1-tarick@google.com> From: Tariq Toukan Message-ID: <7e5d6d30-ed89-8a8e-55c1-a25897937727@mellanox.com> Date: Wed, 2 May 2018 16:31:24 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180427152015.185861-1-tarick@google.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: CWLP265CA0206.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:4e::26) To DB6PR05MB3254.eurprd05.prod.outlook.com (2603:10a6:6:1b::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(48565401081)(2017052603328)(7153060)(7193020);SRVR:DB6PR05MB3254; X-Microsoft-Exchange-Diagnostics: 1;DB6PR05MB3254;3:C/dBsYAUBaWpiD04KQHefKRFzDcYxq6vrEullwDluxyKQkld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sj7uqti2ry6pZv1/Q7AhEsk3ICjeoAbOFT7GVMyLBWqPppDVwG7bjKJHzmIoR0Qq9qCvGlob/rRxfVSdC52VFXcc1PDhVhFvUp6IY+RmW32q1NKZ7+GjkFgjnIEZ4eqms5f5PtyToP5ZOcy/Mf9ZkVVDftjR/Um6KHbo6ECH1LlvaO3/kRH6IYWIDPAY5TL8WkN601pE91tjnv1onjdqQNJKagu/sJHcg0JzqZqUamAdg4hnmiUAvZdIc0bk9FaK0/EBn91gqogYj0MOXfw4jH+pmdhtg1;4:lsOuxjxfIQudPns5P5H7oXKUvJcTyPGb3Mz0/Tv5Y41Nrg96AHypXocj/xFylhi2HqLVxS66REFnmVAxWNcrwdUCDALu6CrEEKk1i7HaVJFednXOnYuLw8BlBiLmX2+mJKvFTF8JGvizgupXDmpFc1j/6NCC8CnCmYvbnDfoVy/8dyRi+eJ0dJKnJmkJBj83YXO8JmOmgDzFMgvwmatlZua1HGWKgsq6mW5Y/ZqjBykWbLV5AeXL6nMb5nfj404jqFhnRbM7tSKBiBDSwKlh5IK6myetMDK5+E8hhj3yWyI4GGiEgU8ef6olkw57p9Ju6UufUWC7BI/vCGDPUbQQkUcxsBAIppj2CuSD/sES8E4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(211936372134217)(153496737603132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011);SRVR:DB6PR05MB3254;BCL:0;PCL:0;RULEID:;SRVR:DB6PR05MB3254; X-Forefront-PRVS: 06607E485E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(346002)(396003)(39380400002)(366004)(376002)(39860400002)(199004)(189003)(6486002)(64126003)(31686004)(446003)(53546011)(6666003)(486006)(386003)(5660300001)(2616005)(11346002)(81156014)(476003)(6116002)(97736004)(65826007)(36756003)(81166006)(956004)(105586002)(68736007)(8676002)(3846002)(6246003)(229853002)(65806001)(66066001)(65956001)(8936002)(50466002)(47776003)(26005)(16526019)(2906002)(575784001)(305945005)(478600001)(86362001)(25786009)(2486003)(23676004)(52146003)(77096007)(53936002)(31696002)(230700001)(52116002)(76176011)(106356001)(59450400001)(67846002)(58126008)(316002)(15760500003)(16576012)(7736002)(186003);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR05MB3254;H:[10.8.1.14];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjZQUjA1TUIzMjU0OzIzOmcySUJTMnQwUmNqUS9vQXVORkpwbCt2QlhW?= =?utf-8?B?ZnBXOHhSVWkyOFpNM3JEZVR0M05LTDBuYUs0MDRKcnRRRFdwaVA1Y0RJRGZo?= =?utf-8?B?cTgybEF4KzNNZS8ya0lUZUhRRlkwTjJKOERaWGpPZXFhS0tmL0p6MWhnbXIw?= =?utf-8?B?SHNkKzR4cjJrVzRwUXJMNnFlMGZYMmZBTmgvLzJvaWhITnQzMHVpanlIVm9E?= =?utf-8?B?VXpQbG4rOE1xRFFZdElOMzdjbWdia0ZZeGRrS05mYXl3cWZzbDJMa3lFOGxD?= =?utf-8?B?SEZVMnZrRTVjQXJPM2hhc3ZjaTVWWWdjbWdxR2NNcXZrT1dmWXllSVhCcE9V?= =?utf-8?B?dm14QzdTYk41OFd0TkJCRm5obGwrVW02TzVhc3dHMnFXR0V1TkMzQ3lIWW0z?= =?utf-8?B?VHZYK2tVa2JTWXdZTGxIb2d2ajZFVUxyOS9xc0ZUQ3ZGUnRzd0w1Vk1mRlFX?= =?utf-8?B?ZU96dGphRU5wanlxYUczR1VHQmJvMEo1NG9qQ2RiQnZjdW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FrBawhwFlPJp+G708uE6RRGylleYA77m2CBR4shcdUcYuxedcQCPr1J9KI/Yq0w0xbzTyo2vu0/rdfiKs2JAH1zTkPk6VZlexaoALc/awNrVPfpp68jgRKx8UV3dlM9bsH9M6JnIfqFoxJ3+Ousi57fY0vMgLPRGKTbjOctN2waiyCsWBMsZabp1C+mGXQdsCNvmPq3QeCE80g6248aqQ+buD3iKvxIFyk0EJqZxeXq+V3eV8LA+4KwyGETkkm10XT/y4AZjOAdpXwxW56MzGwl6t46nIG+r4QpWaZmj4EgdYwyxSGRH1PWI5EU2ELQxxTxTS45HELVc4D3opTbVlz6Y0u1eAw==;5:7wGEoePK3EnjtxMkNhhpM8nMJaJaNl4PJPuYmVVU3FMtrPtpqKRAuD7szY9JBdlsHBBlsYUHx0uWF6Lz5FKScGS99P+iIBu1mTWuI6mRh2ET1JHs9NPvs9qMISy8/YDEMPHCRnw8hByE85B7xHCgFDGVOWqWS8w7W0HIho9E9Cs=;24:uLP7JASH02tfw4FUpl3dEFLzTh+EQ4RKkHcvzpZqkCVP1Xql5dddgEKe7aIMUF5+bh+uLw0nxmwGmYHa/ol7h+8cEn80+/7tFKDA7Cj6gjg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR05MB3254;7:NsfAum7no2eoN0Yy5pMIllQl4dYlXp7oCBu22NOzbfx8Zjq7EiBdTv+ERsoP/9sjbkow/I15T8BodoLjyhX2tKG5KRiGcTmIkDOdekFTSSUTtj9FQat8IqyEH1K5dR7SobnL4PrtFUnSaypsml2JH5O+RdxmbASmllxIN8cM/3BfZPfmoQCgWm/K2D62oSLWiCnzjevxffwEGEDR27QxmBVb07SIs+7ug4W31ClGJqISqnk6+4OcLY4vleIrPSgS X-MS-Office365-Filtering-Correlation-Id: bb76200d-1deb-4750-b278-08d5b031041c X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2018 13:31:30.4950 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb76200d-1deb-4750-b278-08d5b031041c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR05MB3254 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/04/2018 6:20 PM, Tarick Bedeir wrote: > Avoid exiting the function with a lingering sysfs file (if the first > call to device_create_file() fails while the second succeeds), and avoid > calling devlink_port_unregister() twice. > > In other words, either mlx4_init_port_info() succeeds and returns zero, or > it fails, returns non-zero, and requires no cleanup. > > Signed-off-by: Tarick Bedeir > --- > drivers/net/ethernet/mellanox/mlx4/main.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c > index 4d84cab77105..e8a3a45d0b53 100644 > --- a/drivers/net/ethernet/mellanox/mlx4/main.c > +++ b/drivers/net/ethernet/mellanox/mlx4/main.c > @@ -3007,6 +3007,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port) > mlx4_err(dev, "Failed to create file for port %d\n", port); > devlink_port_unregister(&info->devlink_port); > info->port = -1; > + return err; > } > > sprintf(info->dev_mtu_name, "mlx4_port%d_mtu", port); > @@ -3028,9 +3029,10 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port) > &info->port_attr); > devlink_port_unregister(&info->devlink_port); > info->port = -1; > + return err; > } > > - return err; > + return 0; > } > > static void mlx4_cleanup_port_info(struct mlx4_port_info *info) > Acked-by: Tariq Toukan Thanks Tarick.