Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6552635ybx; Mon, 11 Nov 2019 10:50:20 -0800 (PST) X-Google-Smtp-Source: APXvYqxgSiaTjzl99m+SrybqS6R+y88MyrR+pCC3TlEo1+8lvCrimJMUkX/QlhzCjBxEhw+fJUAr X-Received: by 2002:a50:de47:: with SMTP id a7mr27649633edl.77.1573498220116; Mon, 11 Nov 2019 10:50:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498220; cv=none; d=google.com; s=arc-20160816; b=JHahSxVA+IIqaA0F2DDCSSaupzKRPCyNWrEKrgGeoMmjk6PwJQGH+s9Si8zH7HZcqM xrhirreZjV0gbP331pU+jj5HvGd4BJFO8h/1J02HgdSk0kZstdHghBeYeMG5Oqi4DjKs f8CnlhpHWF6G0eyG95Qcx0R3vVTVB/ATkVGZJ/FRLcJkKbqJydmzq2Z+zBOFeIfPnKMY ML+IRwZEycswBXLIv803V5fy1XglkAm7HesZeMxW6Vqz8EtOY3hffNQk0dGSxOSuaJFH hDpIJuZFPuQBXr7bN/kSMFPF3L0ZU/NWnCAbPiL28yzpLyCmyGTb8PilHIUGHkDsCBE1 E4fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nDarPuqhEG4DklqbLmt00FOC1dbXrcoOk1QxqyM/IOw=; b=sL1v78FAeBjvSlgZkBovSRJWUD4bALIInSWFohjTaN8uHs7aFjdKUwfmAsBmclTYkL 3iRf0bYpD7mGO9Y+nprclTBuJAru4rK01F3gckBgGJ9saXOkN8IoY7KSTBU9IqZ+EaIh bAgwkYwtAbUG7DB9uS99+lSu2bLcnt9jR/r8JsSWhBFWl9ae/GJBX0anb3zZ0kb8oS76 FtJaV3lS5yCti1TQlqCumdZjefGa/sOA2geDjCYdaaMOyUmiB4RXjA18E9WnoUNNh6Ii T1bYe346/TmE+OH9Y05dw+GSLGCPlFe7B0CL3k2vgtbqsvnPXfwqhhABdXxIaziRDtfF 9btA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=16Ra9XPr; 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 bi17si12685678edb.430.2019.11.11.10.49.56; Mon, 11 Nov 2019 10:50:20 -0800 (PST) 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=@kernel.org header.s=default header.b=16Ra9XPr; 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 S1730020AbfKKSqm (ORCPT + 99 others); Mon, 11 Nov 2019 13:46:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:39218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727132AbfKKSqk (ORCPT ); Mon, 11 Nov 2019 13:46:40 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A100214E0; Mon, 11 Nov 2019 18:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497999; bh=rl1EgSFBqFlLfdFXiP9mV7W9mkJPYNqVUlCx6ceRKls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=16Ra9XPr0eMJfWSmFxjHdm+5yCiGWanopJWLp61xXhGFJgZC6PtJS+qXVJAsH4j1W RB5N7+FkeBNdWbPs/6yT12ERd0rMSpm3ehPHzUjezLpQQLuKRkCWDdT5A/oy+dIX2t 7x1w5p9iQmmDKj0BYXU3fh1xCsdz05ZPyAdMHZ2o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , Aaron Brown , Jeff Kirsher , Sasha Levin Subject: [PATCH 4.19 117/125] e1000: fix memory leaks Date: Mon, 11 Nov 2019 19:29:16 +0100 Message-Id: <20191111181455.436480315@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wenwen Wang [ Upstream commit 8472ba62154058b64ebb83d5f57259a352d28697 ] 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 Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- 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 2569a168334cb..903b0a902cb95 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 @@ err_alloc_rx: err_alloc_tx: if (netif_running(adapter->netdev)) e1000_up(adapter); -err_setup: clear_bit(__E1000_RESETTING, &adapter->flags); return err; } -- 2.20.1