Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp131873ybl; Thu, 15 Aug 2019 14:07:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeMiT5YdHrEs9dRxMWF3p6URlRAMZ2du3t7ZNo/256yVfThMDdN+UvlpumXZ1tLwm2Nij5 X-Received: by 2002:a17:902:2f05:: with SMTP id s5mr6076258plb.170.1565903235054; Thu, 15 Aug 2019 14:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565903235; cv=none; d=google.com; s=arc-20160816; b=aNWpvHHDv4lqojxq4EOBmt9J6Vy42wP5MuiOmI7H1kMPyaf0R6h8pfG/kkhIG3lKWo wyZiYB5oFax/BZG+3M7mnvsq9/2NGvJrEbdmJeQQ4I5VcGH1bvxERM0FRgVW/14kTo1y W7Aqj3FGlyU6lVkpJC5WyjqSCj7y4EHYmL+EeMB1tMRjH52XPRVnRqvlHx2ndyRU81ws ucwdVRxPMBNWZ5zDG03pztV5/ATX5M24toPm0TfL7MR2ySY9bVYbEbPW0HUMgXVvhOJA DeYEvsqfAIvT8Ot2N0MLajbbJ7yuob/HIMZBIiy4Pvc3YwbMESMuL43msY7I71jWSxCW 2cBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=+XVVA85Z5DjA515P/Vkl59fp8RvkMm9BSaT0uVAMQJk=; b=tl1gjXa4t88kuh0MXaDMLbuKeo9inQoe0OBUEfvqTTVNic/KZazdsCtMiD0FxYdVXU 8WKL4jmfZTxyqMQZKfertF1INwf6gPnEWfFeCjLtmSUpRL8jb1qBxiKG+6hlnrF0iBeK 48fXDSc01JNF7+xrJL2u5VXGTbE+IOu28rLX6bxTYaJzuVaY+EXpLbC9Xj3qzAtPPV/z DOyaUzRqS9HFYXE3Gl+oSjhb+7yP4vRH/BcsWZgcWuetWMfreIdvr+UAn2Uh8qpbHEtQ tAw9Aa1X7T8OI25+gZU2mJN2aisWeO1jSBrQvaHHhAgfxKT4KECp7B2Rv7K35bU/T05h R9iw== 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 r4si2410031pgg.368.2019.08.15.14.06.54; Thu, 15 Aug 2019 14:07:15 -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 S1732487AbfHOUqp (ORCPT + 99 others); Thu, 15 Aug 2019 16:46:45 -0400 Received: from ajax.cs.uga.edu ([128.192.4.6]:59002 "EHLO ajax.cs.uga.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728728AbfHOUqp (ORCPT ); Thu, 15 Aug 2019 16:46:45 -0400 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (authenticated bits=0) by ajax.cs.uga.edu (8.14.4/8.14.4) with ESMTP id x7FKkgUs078312 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 15 Aug 2019 16:46:43 -0400 Received: by mail-lj1-f179.google.com with SMTP id h15so3370707ljg.10; Thu, 15 Aug 2019 13:46:43 -0700 (PDT) X-Gm-Message-State: APjAAAUCnQv/R7mFKHJd8x/tlQ8aT8UhBa5dI4IlDJNLJUOzz2K+s3Sa NhaH/+Uj0VJG2YEaES23MNVpa16QJkXbpf1yv94= X-Received: by 2002:a2e:89da:: with SMTP id c26mr3093675ljk.214.1565902002043; Thu, 15 Aug 2019 13:46:42 -0700 (PDT) MIME-Version: 1.0 References: <1565746427-5366-1-git-send-email-wenwen@cs.uga.edu> <20190815.123430.831231953098536795.davem@davemloft.net> <20190815.134230.1028411309377288636.davem@davemloft.net> In-Reply-To: <20190815.134230.1028411309377288636.davem@davemloft.net> From: Wenwen Wang Date: Thu, 15 Aug 2019 16:46:05 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] net: pch_gbe: Fix memory leaks To: David Miller Cc: Richard Fontana , Allison Randal , Alexios Zavras , Greg Kroah-Hartman , Thomas Gleixner , "open list:NETWORKING [GENERAL]" , open list , Wenwen Wang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 15, 2019 at 4:42 PM David Miller wrote: > > 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. That happens not only inside of the if statement, but also before the if statement, just after 'txdr' and 'rxdr' are allocated. Wenwen