Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp389233ybl; Tue, 20 Aug 2019 22:26:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxd6X6tZyBDv3sV2CB02rwDKCqVdwuUMqu6ynvz38FJbLHnBaEXvwA/PmLpQWuqLaFK/Ie/ X-Received: by 2002:a63:eb51:: with SMTP id b17mr26901645pgk.384.1566365213221; Tue, 20 Aug 2019 22:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566365213; cv=none; d=google.com; s=arc-20160816; b=h1xWzgOBH5tNfZ+Nf+8VwaAZaUa2dffn8t1YVzqpWI0bBuMjbYtfs6MJtu9bq1Vc1J E8cB3iaCryBJmEfcP9i0H0qzUuPi5fBxk3iwF5H+xg22bPJDNiPhQuhvNf9GsdoFkpbE QmysDZ1CTgcdSiiTIqfy4T0sDbNdDHE60Bbuphm0PZoJa4+Ey7yw060eUR6JVhJRAOnl lavIaGJ+KP1QvqbtpJhSNlHICRreyYqBcMbkKWf9wo7fp3ZVRNg5PKC2W6b31ruLvp/J SsvQuy5TsjAT/ZQiXKMypFDtAP3vDAFWp1+3fe8C/4+z+rskHtv0fcWSFSf02I+owaIK ODfw== 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=8jzbFnGqA4KnJX6O7FP/a3aKVv5OO1v3gxYw/j1lg60=; b=CTramkGpc5dYVD7t8j6VeJtqa8Jx5B3CJDxrfYU6EXki+U8Js+JpjkNZdFnw6cOll4 ITH4XiDgyQ6Cy5O3dt+DNzNZbA/1UHMMamt6tR9rBp23agLGbXOV+BbHyli/EcCsqCA9 OWNKRFye09uh8G//bggoWsOG7Sa8UcP9sJhznP/zMggwQP/fJHvdZinhKqQ/cwonuA2C MDu+Xj8mcAFJ470Dsnf3g68GVk1KtWoKt3gjZkIyDu0YGFrsv/g/NfsFULymVMtqPVTO xyF0GQXSk+Ol/BLpEs5hoG/Cn164wefo4J1LfzOWp6Qtnet93ZcmVm48OQ9yzBbuymAL UkKg== 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 5si14350985plx.124.2019.08.20.22.26.18; Tue, 20 Aug 2019 22:26:53 -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 S1727457AbfHUEUT (ORCPT + 99 others); Wed, 21 Aug 2019 00:20:19 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:38127 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726409AbfHUEUT (ORCPT ); Wed, 21 Aug 2019 00:20:19 -0400 Received: by mail-yb1-f195.google.com with SMTP id j199so484515ybg.5; Tue, 20 Aug 2019 21:20:18 -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=8jzbFnGqA4KnJX6O7FP/a3aKVv5OO1v3gxYw/j1lg60=; b=iDlZQ//6KpE0M+iWsT9xArjmVRFoTK46DHXiReyuasjY32uJ370sDvfRv/FJogPKeH E/WRxVTK8+1Mj2zq46fvYIixZKt5FSdr1pXmfPpNqsNX+vLzFjSLdfkdfKcuzTxieLhd a1D/l8IQNcmYt1jEtYNxK2PPZXIprbI0Ev1EQU4+YpERaurQ8RWGQHrwZGK1WFbHv1MB SBf2oh0UfYj5kYhCRMPJ2pMPVxzj3Lh88DOsAnFcYhowkT/ozxB64qvZcU0sgXQBA9tS TBOCtZpBHCyfLkEcKrHOIfp47fTzaw6tXTt4WV4WEKOHU3tZbJiGtCUstIlSmb0HtGfX JCWw== X-Gm-Message-State: APjAAAUeYQi/ZfD/cwPjAQ680gNFgU7QyaPXb1pjfPcT1A8p/+Wqz5kU luItFILeWGQn/2NXZGr326E= X-Received: by 2002:a25:4212:: with SMTP id p18mr22478312yba.194.1566361218158; Tue, 20 Aug 2019 21:20:18 -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 c203sm4034239ywb.9.2019.08.20.21.20.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Aug 2019 21:20:17 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: "David S. Miller" , Richard Fontana , Alexios Zavras , Allison Randal , Greg Kroah-Hartman , Thomas Gleixner , netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] net: pch_gbe: Fix memory leaks Date: Tue, 20 Aug 2019 23:20:05 -0500 Message-Id: <1566361206-5135-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 to the outside of the if() statement. Signed-off-by: Wenwen Wang --- drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c | 6 ++---- 1 file changed, 2 insertions(+), 4 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..cb43919 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,10 @@ 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