Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2031632imm; Thu, 24 May 2018 04:50:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpTEqpb10N94eN7D1WckHmC7P+h8mBCTnRNAQ2ZK15mzRbfds5l62JqhGWSY3x8XjQmoTfO X-Received: by 2002:a17:902:a5c7:: with SMTP id t7-v6mr7120944plq.360.1527162628794; Thu, 24 May 2018 04:50:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527162628; cv=none; d=google.com; s=arc-20160816; b=wo8MJgt1u/vfFMiGunEbesC1nSBNm2HfDK6Zvi4JjF03JPfMXk61Mx/XI0cezqwhFT CHBVxEdBvHQA9jfm8Krrq5IZDKAadT0tiJqrcDt/hVkjtloLkRl7phrry3fGQGwTDCT0 i/k1DYk6gntm2/OpMPRL3oHPJY10lJRB028bwnhpmC0xGI4bZWaT5rzyA5F1czlz3L5+ rL5DFSpthpTbz2ulmun+GIBWHOE8UXX9jlbjsmQ4mQ4PRjdmBxfRNd91C+M/toqBuFC4 laS+WQP1FUEue6wXxWhkLRwDlpOOcl1zgRbCpZmeZshR3RulabqTHckLSEKeUYN8eyTg GB6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=SieXmFKD3FJU97Zpi/fSL2eE8HJAkJmw2cDnMscT6ko=; b=p4qBzh+/fZrldZhjMzKvzadkyDuxQepamBJHt9SbtGnMiR3yyTKiOMtiHMeDoajsjX lL5jnB4vPAkGU6LzfAaQ7HKu+MZl7khGcUCJpB2OGsxGAtyWZ5WI9aj67DaKowPG4A93 Mes3l2ouE2y6Jhsu1bxYIgy87XkUVxkAxik+RhfvczwcdAxv7/hlHhLPhRBn9DT3QF1Q 05cxCHse6pCS/ae2GV+5wUue7TAvciIcNkbwFFRlGs3oG6RKzV87lQhdeAqVLrjrtVsd nkTt6zvzJG3LZy4E4xjT0pYfEl+3EPLSMCCqwizEOO2RFTFcBHDSq13234aMeTkC9IlO sz9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DQwFM0q2; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j2-v6si16931075pgc.350.2018.05.24.04.50.13; Thu, 24 May 2018 04:50:28 -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=@kernel.org header.s=default header.b=DQwFM0q2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969327AbeEXLt0 (ORCPT + 99 others); Thu, 24 May 2018 07:49:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:59306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967008AbeEXJrG (ORCPT ); Thu, 24 May 2018 05:47:06 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C5A9320892; Thu, 24 May 2018 09:47:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155226; bh=xwEOEJWzrfNjEPFyrU1LHX04vaP7Qupibj5o7+egd+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DQwFM0q2Ggl/pPtjUnOy9gVR+QercyxzNQ+Th82od8ZRcsuNwjRW5BRzen23pKig9 2ylbhpMR1/E5UG96XDGiCGLK7NDQuyLkpoEca//qsBTZlxvLJZfhYmjLxFKvmAR4l8 U/ugfzFGnuqTG0tCJZ0oTIband4G8hWSSmM+96mo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tarick Bedeir , Leon Romanovsky , Tariq Toukan , "David S. Miller" Subject: [PATCH 4.9 01/96] net/mlx4_core: Fix error handling in mlx4_init_port_info. Date: Thu, 24 May 2018 11:37:44 +0200 Message-Id: <20180524093605.702786478@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tarick Bedeir [ Upstream commit 57f6f99fdad9984801cde05c1db68fe39b474a10 ] 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. Fixes: 096335b3f983 ("mlx4_core: Allow dynamic MTU configuration for IB ports") Signed-off-by: Tarick Bedeir Reviewed-by: Leon Romanovsky Reviewed-by: Tariq Toukan Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx4/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -2983,6 +2983,7 @@ static int mlx4_init_port_info(struct ml 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); @@ -3004,9 +3005,10 @@ static int mlx4_init_port_info(struct ml &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)