Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp185802ybl; Tue, 13 Aug 2019 18:34:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbqI00jz52nuDxvjZoN2AhZpkgvWThyEWhJqGbIm/yoKUxa2HdNWN/V7bQr6zaynwFCIKe X-Received: by 2002:a63:121b:: with SMTP id h27mr36958889pgl.335.1565746489844; Tue, 13 Aug 2019 18:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565746489; cv=none; d=google.com; s=arc-20160816; b=kTxoJmleUK3Jj+8Wrp99sFWE5W4UPO0mWDJWaTR9LL6eHh9aqfYvSL79xrNY6KgoA1 S8aCFi/c4qOvZpnHtek743tSDkqkA245k9FZPGYwszvIL6/AbleXR4oFLXl8OVP7dX6U QMcJOSMvLye45ivouT0Z7PEV5/2S2xTZgxqqd/K6nt6yXFnP/r8qT0GKb4hros7k9FbI mKVYwF76kpVfR0GHNf5j15XwSVbSjOutwyTGeGnI/FPwivH4UdHuBXPwGOUCGvnzm9RB xgwKch5Y69yaEjqelZrobITWFKJjaTFfrH9ztZMbTq89zW+DYHiagBZxmr8sB1BYQ8IZ FFxQ== 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; bh=7CuXXwlvBZ4dD2S3Pu/3bidV2iYvzmejPU7LB/4HQdo=; b=eGJ7RWfDk1y2K8x9ZSzAWV6gbJxqSPeuF0g7DFJWWXtX59v0uXcUhVoQE/0EN1cbqz XTGWKyNQVIvDYF/ltqv4Pk1aXfv7QRkEYRE9whML+xk384uabxugcO6I2z/Vb7Nc3beC C7rb+chvE4bpyINkX7nG17ePv8Ufgqc1a91ZwjqL4+XYO1Lk/GmSs7CBIKKthwZYRDQ3 vlvb4bF2BZztDr1dD3OIe76oFfyY7/eJdlBJgdhWYphytGb5SfTirKuoeNayPAKHAmru zVEAi9QS+fPertYLfERYL71EGp4e/PBdh4xaPOBLLvHqwIyj+kmOnxYX6kf0JDSLZAcl mlYQ== 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 y5si59799875plk.338.2019.08.13.18.34.30; Tue, 13 Aug 2019 18:34:49 -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 S1726931AbfHNBdy (ORCPT + 99 others); Tue, 13 Aug 2019 21:33:54 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:42296 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726825AbfHNBdy (ORCPT ); Tue, 13 Aug 2019 21:33:54 -0400 Received: by mail-yb1-f195.google.com with SMTP id h8so1870047ybq.9; Tue, 13 Aug 2019 18:33:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7CuXXwlvBZ4dD2S3Pu/3bidV2iYvzmejPU7LB/4HQdo=; b=DtUa5u15Ar0hNUbBGQtp2qJt5ImBHG6LLRjtBtbZ1jJ5mJQeTeK+9BVTwKl2oTt86C E0HKbxU9MV5ji9UIrxfuBVNFxjj9J+Utucl136pTz1YM9lu78fbF4VVjD7Vo3H97WTTv 0yo2yUITfSurEx68L6hRBsaKLLTSBytSHEVDbEWUBYGWGockEuRl9AdJPVQLHFbv672n DaT7jROI+P2LI/+71KY38IVyQFKOodJUM7OeoGRPmSUXxyADqND6E42Wi1/HKNwmmczC d6zqlR9XY5JS1E2rRtFojjybi7ZXaTM2TiYbW44LxOSKfuXXIh32xuUyH6WPlOu3s9BS bTYg== X-Gm-Message-State: APjAAAVutFB/XtYEudk/glYDEKUHN9gGG6Iwxa2FV5jVARstHJ+urUML pxvDUMsieJWSyhdAV+asWT8= X-Received: by 2002:a25:e70c:: with SMTP id e12mr8541928ybh.133.1565746433326; Tue, 13 Aug 2019 18:33:53 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id l4sm23527919ywa.58.2019.08.13.18.33.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Aug 2019 18:33:52 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: "David S. Miller" , Richard Fontana , Allison Randal , Alexios Zavras , Greg Kroah-Hartman , Thomas Gleixner , netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] net: pch_gbe: Fix memory leaks Date: Tue, 13 Aug 2019 20:33:45 -0500 Message-Id: <1565746427-5366-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In pch_gbe_set_ringparam(), if netif_running() returns false, 'tx_old' and 'rx_old' are not deallocated, leading to memory leaks. To fix this issue, move the free statements after the if branch. Signed-off-by: Wenwen Wang --- drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c index 1a3008e..ef6311cd 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c @@ -340,12 +340,12 @@ static int pch_gbe_set_ringparam(struct net_device *netdev, goto err_setup_tx; pch_gbe_free_rx_resources(adapter, rx_old); pch_gbe_free_tx_resources(adapter, tx_old); - kfree(tx_old); - kfree(rx_old); adapter->rx_ring = rxdr; adapter->tx_ring = txdr; err = pch_gbe_up(adapter); } + kfree(tx_old); + kfree(rx_old); return err; err_setup_tx: -- 2.7.4