Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp241930ybl; Thu, 15 Aug 2019 16:30:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWDVDDSzBfS1N5rsehLXOWd8D2AGEZ0afXBY9z6DGGyucvA/IMpxcOQvDy2lXGKOwNgamR X-Received: by 2002:a17:90a:9486:: with SMTP id s6mr4580955pjo.0.1565911813107; Thu, 15 Aug 2019 16:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565911813; cv=none; d=google.com; s=arc-20160816; b=gUDiqgy48yeX5nnBpbH27cV6xJtk9ac3zp1DLqDEPWC+wbDe5jN95PqfIIUYb+e1I3 Bl8v/ZoGVUTqO+158Z0gYehx3y7ZvHdFUUQno/0vzTY9WRJ+yeCRTfXD1GOZ2fTzaYH5 ksvFNbia8/JkmrOZozQGpOKrS1cgCDEXw2MYFXT8xkK8R+uCR51m9n4aHvjORQhSXiiB GIC/h9PlxoukECp/MS9xS01fyM/2eTPnlvtPEFCFBgrjpL0MBRWM6EGhIWpO0OAskjPk NH3S4Hf0CIU6g6mRzoFWGqe0AwnfmxDe+uH3DDLkTZz+MiRWD84mn772/b7I7YfiGjJO TL3A== 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 :references:in-reply-to:from:subject:cc:to:message-id:date; bh=3+dkqKPlkIbRjdxAwvBIdXHA6tWbmBaLIIFbESnBBIE=; b=YQP4jhv1z6G0gicTSLGT7Hi5LWMYa1TKyOoIkdUhd3X+oxpukkEqH3RtpjWppdpALU rln3QnZ1XVEm/UgT6a82+RsJG4Oo01HXi89s++8eQk9ljrvJvT8WMjvcCT037iwZbm4S jpEr6Z44fw/RemXmjklXLLQcIy6l+Df1AqrlmCr7tp0hQlSz9aVR8Pshj7zrXy0tZfRA ZQRBDDiBILQpMSqlmw8DmmXBx3kTT1O/SHZqIZbvE0hTf4dA738QNwLC0nNLNwWxjGqm CkOim5adhRsD5DlZ5/ZQrzI0xNj0lOvQgOK+LFi0klQxzEWlJHir1uI9C56FUhvatIfe 29Pw== 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 d3si2974029pfr.161.2019.08.15.16.29.56; Thu, 15 Aug 2019 16:30:13 -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 S1732438AbfHOUme (ORCPT + 99 others); Thu, 15 Aug 2019 16:42:34 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:49960 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728898AbfHOUme (ORCPT ); Thu, 15 Aug 2019 16:42:34 -0400 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::d71]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id DA67C1401C513; Thu, 15 Aug 2019 13:42:32 -0700 (PDT) Date: Thu, 15 Aug 2019 13:42:30 -0700 (PDT) Message-Id: <20190815.134230.1028411309377288636.davem@davemloft.net> To: wenwen@cs.uga.edu Cc: rfontana@redhat.com, allison@lohutok.net, alexios.zavras@intel.com, gregkh@linuxfoundation.org, tglx@linutronix.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: pch_gbe: Fix memory leaks From: David Miller In-Reply-To: References: <1565746427-5366-1-git-send-email-wenwen@cs.uga.edu> <20190815.123430.831231953098536795.davem@davemloft.net> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Thu, 15 Aug 2019 13:42:33 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wenwen Wang Date: Thu, 15 Aug 2019 16:03:39 -0400 > On Thu, Aug 15, 2019 at 3:34 PM David Miller wrote: >> >> From: Wenwen Wang >> Date: Tue, 13 Aug 2019 20:33:45 -0500 >> >> > 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 >> >> Why would they be "deallocated"? They are still assigned to >> adapter->tx_ring and adapter->rx_ring. > > 'adapter->tx_ring' and 'adapter->rx_ring' has been covered by newly > allocated 'txdr' and 'rxdr' respectively before this if statement. That only happens inside of the if() statement, that's why rx_old and tx_old are only freed in that code path.