Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp333120ybl; Tue, 20 Aug 2019 21:12:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqygE3DQH6dY3tuCLrqiFAPj2Z8GJdXGJrYBooSaMRK8Hg+8vpBM23HC4gUYoB3PjqPR6MfD X-Received: by 2002:a17:902:24b:: with SMTP id 69mr30496371plc.250.1566360734398; Tue, 20 Aug 2019 21:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566360734; cv=none; d=google.com; s=arc-20160816; b=GF68INHP609SKN9Yd6GmZG6HlypbqK/nnXk1B//QDKnTMYPUHiWK5goHbtNzDqWUTT vEXpQtAoFRDLgop+LR0bT51zxd+MoetyOFUUfYcWE7yatarWvzsYzKZUAEqGiex8Zzpx awWmkfYMUu7MgEYoJjsAvsJFAd1qtqrhYj092IN1O11+QrHhufCzzMH8QHoKzcpLZa0L 6+1VMtFPRDuXPJqmmWCUclxPwjh9hnCMKcIucSg+1O0aX6HXZMIyaHvRm9wFJ5GtWofu NWYcgHjKySmZ01eqBbSmb6lyqo5u2R00xZchx8VfjYBx60G6ZJqJK4dQ8LRA4ZTo9IKx qDxA== 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=OclObYsokXw/4agn6aGeoC463eJcBOaVyM5zhrCh3us=; b=u/zO4ZMjNZu1FH13weOtOE7MWb+utU8xlJJj1mI5l2kz+hDBq31+LB/ozyJlkdQ2Cs Q1PPUAdPuf5xitW4W5t2Sv3b37zytrDX7Stz8VNe/kUKg/MA0M7RWsMZXj8hPfRfbm+h WHxfgQ+UT3JP+nUEwuNIwz1xUijkRL5/dnQVx/J9tKV65kRANDMHqpFluWC0JeeyjvZY 66GgH4uJAHQ98DoBROQpDJ1k37hC/OgcspLmHhV66Crphlzsap2aweo/qHQPQ8jLuzAM /PUr4t3jojTpdIuiqf5PBzeh+OD0H7jzJAU2K+7JIjYWZSU4kB2k7ZG/+Dw+TV4+ljz2 3zbQ== 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 g7si14212368plq.360.2019.08.20.21.11.59; Tue, 20 Aug 2019 21:12:14 -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 S1727431AbfHUELM (ORCPT + 99 others); Wed, 21 Aug 2019 00:11:12 -0400 Received: from ajax.cs.uga.edu ([128.192.4.6]:44078 "EHLO ajax.cs.uga.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbfHUELM (ORCPT ); Wed, 21 Aug 2019 00:11:12 -0400 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (authenticated bits=0) by ajax.cs.uga.edu (8.14.4/8.14.4) with ESMTP id x7L4B95u068890 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 21 Aug 2019 00:11:10 -0400 Received: by mail-lj1-f182.google.com with SMTP id e24so769093ljg.11; Tue, 20 Aug 2019 21:11:10 -0700 (PDT) X-Gm-Message-State: APjAAAUq0yZzL6KKQVRoSD/MJUT2YKYwNFKyrZDwhnZCArGHxDque/jE Hlxe7elNUqmlR79Bwfc1FqIPCqIVxhjkxtiCQIs= X-Received: by 2002:a2e:3c12:: with SMTP id j18mr1434819lja.50.1566360669574; Tue, 20 Aug 2019 21:11:09 -0700 (PDT) MIME-Version: 1.0 References: <20190815.134230.1028411309377288636.davem@davemloft.net> <20190815.135111.1048854967874803531.davem@davemloft.net> In-Reply-To: <20190815.135111.1048854967874803531.davem@davemloft.net> From: Wenwen Wang Date: Wed, 21 Aug 2019 00:10:33 -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:51 PM David Miller wrote: > > From: Wenwen Wang > Date: Thu, 15 Aug 2019 16:46:05 -0400 > > > 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. > > Then the assignments inside of the if() statement are redundant. > > Something doesn't add up here, please make the code consistent. Thanks for your suggestion! I will remove the assignments inside of the if() statement. Wenwen