From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam02on0096.outbound.protection.outlook.com ([104.47.36.96]:62018 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388614AbeITIbT (ORCPT ); Thu, 20 Sep 2018 04:31:19 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Bo Chen , Jeff Kirsher , Sasha Levin Subject: [PATCH AUTOSEL 3.18 3/4] e1000: ensure to free old tx/rx rings in set_ringparam() Date: Thu, 20 Sep 2018 02:49:48 +0000 Message-ID: <20180920024943.58781-3-alexander.levin@microsoft.com> References: <20180920024943.58781-1-alexander.levin@microsoft.com> In-Reply-To: <20180920024943.58781-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Bo Chen [ Upstream commit ee400a3f1bfe7004a3e14b81c38ccc5583c26295 ] In 'e1000_set_ringparam()', the tx_ring and rx_ring are updated with new va= lue and the old tx/rx rings are freed only when the device is up. There are res= ource leaks on old tx/rx rings when the device is not up. This bug is reported by= COD, a tool for testing kernel module binaries I am building. This patch fixes the bug by always calling 'kfree()' on old tx/rx rings in 'e1000_set_ringparam()'. Signed-off-by: Bo Chen Reviewed-by: Alexander Duyck Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net= /ethernet/intel/e1000/e1000_ethtool.c index ab3d94d0c731..615d2145f411 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c +++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c @@ -646,14 +646,14 @@ static int e1000_set_ringparam(struct net_device *net= dev, adapter->tx_ring =3D tx_old; e1000_free_all_rx_resources(adapter); e1000_free_all_tx_resources(adapter); - kfree(tx_old); - kfree(rx_old); adapter->rx_ring =3D rxdr; adapter->tx_ring =3D txdr; err =3D e1000_up(adapter); if (err) goto err_setup; } + kfree(tx_old); + kfree(rx_old); =20 clear_bit(__E1000_RESETTING, &adapter->flags); return 0; --=20 2.17.1