Received: by 10.192.165.148 with SMTP id m20csp785498imm; Thu, 10 May 2018 00:03:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr27rTIsaFglA4wjekAfDmNrwadilppi2yV9QUxv377LCWOghUPF1/6KmCZZzWaRWctwlyj X-Received: by 2002:a17:902:6b45:: with SMTP id g5-v6mr238984plt.67.1525935786334; Thu, 10 May 2018 00:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525935786; cv=none; d=google.com; s=arc-20160816; b=IaCwRQqVAh6zlWobtgYclORfyUkhJS+2ZAdSd519aRwBJZP2HmJgtR54PQaLBNM5Ca ajAOprbH8JZR7lS/L1Sv4OTwTep3RWuUmGVK9qg2iw671/ydWLpyUXxnT1Z+j4J3p2uD W3SVrboghDHVwP/p04NVl0A7MTOhYzCXkFWfvAIcTbj2oSAntPhpZSd3JZe+vr7gXMwS eT6IsQO3xp7DUB9RmiwKAnMyYhdW/RWyQCBmMS3ZRdNOId53w5hRIHv9wP5kR4CDvyva kSb4bwsuRBKGwJiIg9249lwey3dpWfX7mEjvh81F7VRhS+2AQ8Ib7FB7qz9+YxajMUNd 1GNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1xI10eBQ/Rs00oJVZiRjLsjKVY+cdC2SxmiQ30TkU9c=; b=ZBvXuU5DaEmXLOhgIsFA/rrhtZTkkzu3PynnN8+7B0aM+bNiUIfmGEXiCUSdEEah9C 5HV5nTlujTBw/fRtIA7V/UOv9ODYDWVRvKtx0pwMhwwKZ16IYBKe8gzbKamURhk07fBr I/Pw2qriEKgvv3PRMqAsJibFNY5rNunL0WDNdfDtnwT9IR9c+O2Tb5y9tBCnl8qN/VrW f20rQnXUyR1tdFqvJT08b4otD3OsPm/yPFRZGdOUHwxACVsSxqDSc6pwdtzrTmC9G77T f3lgdU5UniZbndWuLGmOmHWB3bQuY1XnCCYqcAX4IBK0INCrevYHyOEDCPVmwP4E07+h 9vlA== ARC-Authentication-Results: i=1; mx.google.com; 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 b36-v6si170991pli.30.2018.05.10.00.02.51; Thu, 10 May 2018 00:03:06 -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; 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 S934241AbeEJHCZ (ORCPT + 99 others); Thu, 10 May 2018 03:02:25 -0400 Received: from smtp06.smtpout.orange.fr ([80.12.242.128]:23834 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934110AbeEJHCX (ORCPT ); Thu, 10 May 2018 03:02:23 -0400 Received: from ubuntu-CJ.home ([86.244.116.1]) by mwinf5d12 with ME id kX2F1x00L01t9Ri03X2GXB; Thu, 10 May 2018 09:02:22 +0200 X-ME-Helo: ubuntu-CJ.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 10 May 2018 09:02:22 +0200 X-ME-IP: 86.244.116.1 From: Christophe JAILLET To: davem@davemloft.net, tariqt@mellanox.com Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] net/mlx4_en: Fix an error handling path in 'mlx4_en_init_netdev()' Date: Thu, 10 May 2018 09:02:26 +0200 Message-Id: <20180510070226.19575-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an error occurs, 'mlx4_en_destroy_netdev()' is called. It then calls 'mlx4_en_free_resources()' which does the needed resources cleanup. So, doing some explicit kfree in the error handling path would lead to some double kfree. Simplify code to avoid such a case. Fixes: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings scheme") Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index e0adac4a9a19..9670b33fc9b1 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -3324,12 +3324,11 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, MAX_TX_RINGS, GFP_KERNEL); if (!priv->tx_ring[t]) { err = -ENOMEM; - goto err_free_tx; + goto out; } priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) * MAX_TX_RINGS, GFP_KERNEL); if (!priv->tx_cq[t]) { - kfree(priv->tx_ring[t]); err = -ENOMEM; goto out; } @@ -3582,11 +3581,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, return 0; -err_free_tx: - while (t--) { - kfree(priv->tx_ring[t]); - kfree(priv->tx_cq[t]); - } out: mlx4_en_destroy_netdev(dev); return err; -- 2.17.0