Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3635820imm; Sun, 13 May 2018 16:39:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoC3k5AawlVQ6w8Y6HFuQM444ubDi9pK2oucFgqyhKlj+6vAGYO2DyE4CEQKQqij648hQV/ X-Received: by 2002:a63:b007:: with SMTP id h7-v6mr6475126pgf.448.1526254763870; Sun, 13 May 2018 16:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526254763; cv=none; d=google.com; s=arc-20160816; b=v9h3BYFIyWmTlH4PS+zZaqNR3Hbplvfc8J+X8fRjs/JCaso4uuTGIVmrrEpaHwqcf8 NcjA7DeEibV8hn55KBDOSlrnUf8Fu8UdbNl8nJV/s8DOktIxIXD8b/6ZHwUf/dNS3Ibe g3jNqTpN+rS1waQcaPyTz9vRiuGR5el8e/QiNcX+A/MvNGcMN/xXvgHLp9rqbBrBQV9B DNA96jMJBw58QMI1UMxD3KafwrVijLpIVwPoo5o7E+vHbiCUjY+eRw+9BHMPMJnGk+Wx sH+gaEWQSdDlTqGwTGDdeaFtMcgb8t0lGZrYl/KTgQ87CrBjWGiczs/l1Q6o8Ylj0QxN CU5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:message-id:date :mime-version:dkim-signature:arc-authentication-results; bh=7YqH/ABEwkf/92fMuG+Hm3+TAT0EHJEx2qrWFob8VWY=; b=oWGMXELDfjANVRAhU+BS5r3msbbCRjQ0cxkRY1hkpSn+j7O2upi+x/SemsyXqHxOHw Gm27S0hPfZH2Aqd+MCtwyGMP8uBcMPNrnJGolNRIFVrcJR3GxR7hkjpHIFUppQeqZywK ouM6c1kIel3rrcKIHw4XWgD/Sc5dIsqHDKQNOCOu9Jsrq0fIlvAqUoAx1dEpiNxuuNie 76oNCIpApLShYbL9fEpreI8wBUooDmmddYr7XSmFoq4fsh5zXD6qnX/vDEiZJMLkwSLB uayW34ep4FW1Z8Itisc18Juxkw2JoP7vhviAq8lpS1y0AK50D0R2rVl73jWUGGUxhZRH PNhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qo7Uxwg3; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w18-v6si8323173plp.159.2018.05.13.16.39.09; Sun, 13 May 2018 16:39:23 -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=@google.com header.s=20161025 header.b=qo7Uxwg3; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752026AbeEMXix (ORCPT + 99 others); Sun, 13 May 2018 19:38:53 -0400 Received: from mail-ua0-f201.google.com ([209.85.217.201]:37820 "EHLO mail-ua0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751219AbeEMXit (ORCPT ); Sun, 13 May 2018 19:38:49 -0400 Received: by mail-ua0-f201.google.com with SMTP id u23-v6so14661270ual.4 for ; Sun, 13 May 2018 16:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:message-id:subject:from:to:cc; bh=7YqH/ABEwkf/92fMuG+Hm3+TAT0EHJEx2qrWFob8VWY=; b=qo7Uxwg3QOTdk2Fw1Z3ziCEbnjO+qySIZvTVZeMfq4hjoveknvyeKoYcHRJkijMDlS goxGUFZ+dNtot9IDRiKKzQfVPmUz+OKuAt+aQBlV9cdkqABH0xQWplP6uQVEyIKvG7FN vjKpyxzeNO9EOFXSOuXqSMpxRjZX4ZM3z+wvU7p3DDEvaUS49OPLd4TxUXUR5hmSep6x h/w3WNAhmNvzmol5kmgC0xwev9ufgbhG3xG6nMVaSEK35urOwMzo8nJD5osIit0McHnC 5aIHDTCizHum+sPPYXMYmyQUMv6fHuCsVc5sguEljLF7p9mgarXAJTHmqvLIVGCNnt59 R5Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=7YqH/ABEwkf/92fMuG+Hm3+TAT0EHJEx2qrWFob8VWY=; b=VEzFc+H+Ku8w7SFxOv0IAdH0iJopk2d/Jf/Ja5AgeZdnoVctKJ2gSoSoxyp7IL/kf3 N9O/b8gVYVyHHPdruP+QN6kDUok41H/BbA3KzVpepfDMr6hm10pC36jO9GtS0zysxHCH IiFtjQsl7K15ah0f1zxYud3DDUbq6mRuwKjmsi4rgsiQxrBBQsJT707V6itdYWKGXfRM km9jHM/Eg37kHUPkvGLgJxZJI7sX+DU6uM1PHt1sJzrjhRCP6/nahFYbxvx1Jv49H+sd 4usx6PcfCOutz8Kez7RJf1WGmeqbTK51AfSx8sZV/D+HnroWkkQbqZyg/1nVGDaAQxQT mAIA== X-Gm-Message-State: ALKqPweCPTpDeLx74JxUf/V6ilwRyELBRb6iedHCHwWyLfdSaahFrLii ucz1ubSp/FplRu4HTlN7focKgrkhFw== MIME-Version: 1.0 X-Received: by 2002:a1f:3002:: with SMTP id w2-v6mr9293566vkw.15.1526254728511; Sun, 13 May 2018 16:38:48 -0700 (PDT) Date: Sun, 13 May 2018 16:38:45 -0700 Message-Id: <20180513233845.135290-1-tarick@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog Subject: [PATCH v2] net/mlx4_core: Fix error handling in mlx4_init_port_info. From: Tarick Bedeir To: tariqt@mellanox.com, gthelen@google.com, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, tarick@google.com Cc: Greg Thelen , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Tarick Bedeir 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 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 --- v1 -> v2: Added "Fixes" tag. --- 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) -- 2.17.0.441.gb46fe60e1d-goog