From patchwork Mon Aug 12 05:59:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenwen Wang X-Patchwork-Id: 1145780 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cs.uga.edu Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 466f2V0yHDz9sDQ for ; Tue, 13 Aug 2019 00:52:18 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id AAD802152E; Mon, 12 Aug 2019 14:52:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zfsbVLsc98K1; Mon, 12 Aug 2019 14:52:14 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 5AA722152F; Mon, 12 Aug 2019 14:52:13 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 7A8D61BF29F for ; Mon, 12 Aug 2019 05:59:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6C455854E8 for ; Mon, 12 Aug 2019 05:59:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nf8VdivBB3bJ for ; Mon, 12 Aug 2019 05:59:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yb1-f194.google.com (mail-yb1-f194.google.com [209.85.219.194]) by whitealder.osuosl.org (Postfix) with ESMTPS id 88219854E3 for ; Mon, 12 Aug 2019 05:59:28 +0000 (UTC) Received: by mail-yb1-f194.google.com with SMTP id b16so6918996ybq.0 for ; Sun, 11 Aug 2019 22:59:28 -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=N6oSMRPpHGkQ7E+kK6e4vXB5ZZOBX+MrIVovGvsXigg=; b=UudQMvinKPFXE55tLONrW5T/sib3WWzTwe6yEKcjsqi9iVjt5cMD8XBQ5QH9U995Fa wnpq9UWLPJoJxFjGUVe9Xqjw0KlwpkIsGql68vxeQbIhg3u42V1qcIFodXEcfJT++Syv hDgVSLKFDGC2cN3EXHB2dEDhdN/PGfEqVr1YVaPVvzadyPPhfNWktY21dPjfufbbYwAd P5ljjaHHg/5T4YJqZbqxA0Pbq6808+Jjtl+GFuWXODmQl7F64LJLR4n47xpwx/+yCaTR YF4IZQ8eG3f2DSkLbJM1quBoKcdiphERmv69anm/jAp4ovaPLdmKFLpQbbCdlAfr/yOl H62w== X-Gm-Message-State: APjAAAXeXqfa0wqmrRQwJ2Ceid6HRkF1qhaZw+oHZMsdo48rdBMmB6Pc fqNqHBpiTGbFNB07pTsnv9I= X-Google-Smtp-Source: APXvYqyH7bGaVBWLSU8sEzfL/N45LAWNBbDKUHxF98WHxf0lYev6I/BUIG/ZR/mT8bKm9nE2BGn1Zw== X-Received: by 2002:a25:d794:: with SMTP id o142mr9107179ybg.384.1565589567579; Sun, 11 Aug 2019 22:59:27 -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 e12sm24721471ywe.85.2019.08.11.22.59.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 11 Aug 2019 22:59:26 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Date: Mon, 12 Aug 2019 00:59:21 -0500 Message-Id: <1565589561-5910-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 X-Mailman-Approved-At: Mon, 12 Aug 2019 14:52:11 +0000 Subject: [Intel-wired-lan] [PATCH] e1000: fix memory leaks X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:NETWORKING DRIVERS" , "moderated list:INTEL ETHERNET DRIVERS" , open list , "David S. Miller" MIME-Version: 1.0 Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" In e1000_set_ringparam(), 'tx_old' and 'rx_old' are not deallocated if e1000_up() fails, leading to memory leaks. Refactor the code to fix this issue. Signed-off-by: Wenwen Wang Tested-by: Aaron Brown --- drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c index a410085..2e07ffa 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c +++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c @@ -607,6 +607,7 @@ static int e1000_set_ringparam(struct net_device *netdev, for (i = 0; i < adapter->num_rx_queues; i++) rxdr[i].count = rxdr->count; + err = 0; if (netif_running(adapter->netdev)) { /* Try to get new resources before deleting old */ err = e1000_setup_all_rx_resources(adapter); @@ -627,14 +628,13 @@ static int e1000_set_ringparam(struct net_device *netdev, adapter->rx_ring = rxdr; adapter->tx_ring = txdr; err = e1000_up(adapter); - if (err) - goto err_setup; } kfree(tx_old); kfree(rx_old); clear_bit(__E1000_RESETTING, &adapter->flags); - return 0; + return err; + err_setup_tx: e1000_free_all_rx_resources(adapter); err_setup_rx: @@ -646,7 +646,6 @@ static int e1000_set_ringparam(struct net_device *netdev, err_alloc_tx: if (netif_running(adapter->netdev)) e1000_up(adapter); -err_setup: clear_bit(__E1000_RESETTING, &adapter->flags); return err; }