Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1924354imm; Thu, 24 May 2018 03:01:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp6zzafJP8shQk2m7/0B2PiDWPTeO13LHeuZXQT51im0hCY7p+2SoYuZtqoOlQBoI6UPL7e X-Received: by 2002:a17:902:7e05:: with SMTP id b5-v6mr6503424plm.230.1527156110770; Thu, 24 May 2018 03:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156110; cv=none; d=google.com; s=arc-20160816; b=kkNXdqgUZBK9djvApyixLm0zJirABSqgPsKJ5hv5zJqm7yax7N304SFln5PIREPvyz dBbd7yQn375Nz1dn8MvDPMZsvrpwMPIgXjkEFO5EsIeiQVvFCNV8rbTVlif4K1D5Ho2x /nXofqyEQJvZFZEbxduKvfBN6aMR1eWh2uq8hC3i/s2NjK7DdT1YZ5aiQ7rDDUv/Zlig rhYkU6iaZw2FEIJvwqSoonxgUMFPAmdSfFOJOCJYDsYR1FdB911dhrTzsrd3ehbUuWys V0+BRnFVkF9/HHDMJkFCMCotx3547wfLEG45o6j+TO0lR8qJo5Uc+dGP5ApwE+HfuYhU M0aQ== 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=GwXCXX+98CUs0S5cpSIHI4dcEzSElbjIJf1+kcFIGWc=; b=elaPSQYXwNsttz4ZHJqxmZ3H/Qkal8P/4dMRhAIHkcrIbZv6Va0wiWbmHPZJC6OHH1 6BjiJeEeG1G5O1SMHcqpypcpTsOUYhoGU9GUpWTG4nCpJV8nP995TAaCQdhYnBdbH/ua eSgxCwyVo12UD/r0bqAYET29BonJYW6aQITI3UnU/bav/3SOHWbgJnrpZsnNWOtJbd6G RljSsw1Djpnoru0vs2vrmWnaEfaFCqTm6J8kIzVhGbq8btNLcm0UlpQyfuDHF19Feoh6 o2tQiBS3P3H2R9P92qlU9k0xYqhZuH/C+Ic0NPd3XjxKG/Hlk9VqnEtWJnNLq6LZOr5O gh1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EZupQmOr; 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 c3-v6si20625057pld.593.2018.05.24.03.01.35; Thu, 24 May 2018 03:01:50 -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=EZupQmOr; 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 S1030833AbeEXJ7x (ORCPT + 99 others); Thu, 24 May 2018 05:59:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:41042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030798AbeEXJ7q (ORCPT ); Thu, 24 May 2018 05:59:46 -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 098B120870; Thu, 24 May 2018 09:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155985; bh=dKrnKpBwHU0D68V8DmVO1Vhp5Il9ZZ7iIhVkxuP5OT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EZupQmOrb3j2AN51nzxw82fJAjSlZDOM0qS6hveVDXdD/iSZbq682pduvWxNQuhi/ bh8mSSFjbH8MwPaOdMxONz8L+usC3ove75hsGiJF7of2OTdT7FdqknDrHwcfaOIcp/ AHYn92uJshsBcfd+m7NUef7mPLsCLPm6rcMF/k4E= 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.16 003/161] net/mlx4_core: Fix error handling in mlx4_init_port_info. Date: Thu, 24 May 2018 11:37:08 +0200 Message-Id: <20180524093018.765532985@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.16-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 @@ -3007,6 +3007,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); @@ -3028,9 +3029,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)