Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1539905ybk; Thu, 21 May 2020 09:13:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh+d2Km/VXZaG0KUuEgxNXcQ0DFH8buRUD7Xdtglg7rxTdwiuJWFsM1h8nNYZr/d12dnYk X-Received: by 2002:a50:b082:: with SMTP id j2mr8300272edd.201.1590077602228; Thu, 21 May 2020 09:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590077602; cv=none; d=google.com; s=arc-20160816; b=UyJFB9RpmqdvHY81H0gA0rDYMLRuThQZu4VUQ+0ekcnmm23cGISW38scwgCiaf8duk xtYj77rdClrbFy2DyztRj9m7VRijN1XkxMrmrkeRkaH2T0CkYUz62DHcIQxBOZXrwJA6 zzTVT+Avpt49TCRrLvWjxRFrgn5hqslRrvPg0Lb4XoMXhgURK86HUefegrwh38lrBPeI W2kMZufSH3kS9Vtbm9QAduwuVb6XYibXfnQmiNXP4dZTLgWAhoCz2jRuVEevRWzXAeLG l0sM9nd2O/OZbFx1bt/0aaNvjvtNIOaACvv6GsXbkawQfdtAJak2qsWa0VnR7XQwyDA+ VP5A== 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:dkim-signature; bh=+gc76dvAmcnKyafrzIlIXk+cdWsPwaRbHG7m3tGh9Qc=; b=Mzb42rl9vOT15Z9kmbzF0Gz7JHft6TTRT+dGZJvwnRk8/ZfY4sxAh7FVZ8hwKL+akL Jzl3BK/XmX+ayjbc0nMW4AB0Si5b0LWQb0AV2lDxvvahmwXasDwmkNpHBCeGaAqVA1bk Ts5cgSUkTydf2ocfa1sWjnbn7cw7DEVeH5WB3/MNgEjiukAV09QA5SG9bdEI2EKvdD4x yTuy8an411cifsPALDThJQLX9LtJYRA7XD2fmnFna5ISlAUqGA+AKp3MJ2bfb5GzPA6g D07EoJNzEEQW7W6UdBeN2TUYx5ZVYh7rvOJMfHAR0OiZlwCRG6TnoSzJPP8vjP2GrutA K9iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mQCnSMEQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m22si3801177eje.448.2020.05.21.09.12.57; Thu, 21 May 2020 09:13:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mQCnSMEQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729549AbgEUQLI (ORCPT + 99 others); Thu, 21 May 2020 12:11:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728339AbgEUQLH (ORCPT ); Thu, 21 May 2020 12:11:07 -0400 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 463F6C061A0E for ; Thu, 21 May 2020 09:11:07 -0700 (PDT) Received: by mail-yb1-xb42.google.com with SMTP id r128so3084711ybc.6 for ; Thu, 21 May 2020 09:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+gc76dvAmcnKyafrzIlIXk+cdWsPwaRbHG7m3tGh9Qc=; b=mQCnSMEQGZ6tabeU1j68y7o6DGhmRJOY0Kn6mMfHvBIUAWq2O/ODgrivjbSM0aX8db daxjooLBGVHOTfaY+n4/A/E6kHQJ0IjceexQRI0mH/rzdstUMjHvV2v/MXoOeAKEDs7T LeLmAYybUL6z77zumQPOWHGFq1XQI4Fu5zDfM2OC3mCZ1QKwpw50b00ZP4gL+e3nDj1W dDVH+lgDApbAY1eEVNqw+B7RXkv89SBH34rPo4oYv+CEzKw3Z6et9yuy2VKyP1AFAx0F FCy6TqqqM3phM9gDvlPQlnbAk46Snr1wMkAqwaImFhoDHzXU8oSLQBBwzN80CrwFYFzL xJLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+gc76dvAmcnKyafrzIlIXk+cdWsPwaRbHG7m3tGh9Qc=; b=sTmQYIX3pFKopsVQYb3p8BnnJy4oh8SD7qbg5k2hZvVsly/XWzgmPcy6P0Ko1hepM6 7Akunvo4YrLOdstfQzC4MRZsB+MKX5DADkYcP/zJEaw4ZIMZbUBZCGdg10N+SsdEe9Gz 0vYRlrYfKewb1qpnktIS7TaajYPwXLChiCWbgB/GjMPQMO/8aEcAKfpk/FvMP203sZMH taV4t5lJOSuyRz6uKpn/4fedUJ0zBGhTdooH4bW/rgc9xi+Q4EPdfQCLnJADz8HHOFu8 NEIL6zGYeeaJbP6ZCn8sbLXdD0HI6c0HKQfAN+G1FkMUbiIPqKbyTvCOR1uW1ucggf7J IXYg== X-Gm-Message-State: AOAM532mQPqPhBufBOp5tJH1cpK/M3GCrAkLswo2LAqc5Uc7jza3c1la 5LTOhiFC67JGtIjP02ObjbK4n1dVROI7yLPPZU0V/g== X-Received: by 2002:a25:d450:: with SMTP id m77mr16088061ybf.177.1590077466196; Thu, 21 May 2020 09:11:06 -0700 (PDT) MIME-Version: 1.0 References: <20200521133218.30150-1-liwei391@huawei.com> <20200521133218.30150-2-liwei391@huawei.com> <20200521155400.GA14034@kernel.org> In-Reply-To: <20200521155400.GA14034@kernel.org> From: Ian Rogers Date: Thu, 21 May 2020 09:10:55 -0700 Message-ID: Subject: Re: [PATCH 1/4] perf metrictroup: Fix memory leak of metric_events To: Arnaldo Carvalho de Melo Cc: Wei Li , Alexander Shishkin , Jiri Olsa , Mark Rutland , Namhyung Kim , LKML , Li Bin , Xie XiuQi , Hongbo Yao 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, May 21, 2020 at 8:54 AM Arnaldo Carvalho de Melo wrote: > > Em Thu, May 21, 2020 at 09:32:15PM +0800, Wei Li escreveu: > > From: Hongbo Yao > > > > Fix memory leak of metric_events in function metricgroup__setup_events() > > The leak is there but this code has changed a lot recently, please take > a look at my perf/core branch and keep Ian Rogers in the loop, > > - Arnaldo Thanks, I'd posted the same change here: https://lore.kernel.org/lkml/20200508053629.210324-10-irogers@google.com/ but it looks like it was mislaid. Arnaldo, I can re-post that patch or Acked-by this patch. I'm easy either way. Thanks, Ian > > Signed-off-by: Hongbo Yao > > --- > > tools/perf/util/metricgroup.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > > index 926449a7cdbf..69bf0f4d646e 100644 > > --- a/tools/perf/util/metricgroup.c > > +++ b/tools/perf/util/metricgroup.c > > @@ -184,6 +184,7 @@ static int metricgroup__setup_events(struct list_head *groups, > > if (!evsel) { > > pr_debug("Cannot resolve %s: %s\n", > > eg->metric_name, eg->metric_expr); > > + free(metric_events); > > continue; > > } > > for (i = 0; i < eg->idnum; i++) > > @@ -191,11 +192,13 @@ static int metricgroup__setup_events(struct list_head *groups, > > me = metricgroup__lookup(metric_events_list, evsel, true); > > if (!me) { > > ret = -ENOMEM; > > + free(metric_events); > > break; > > } > > expr = malloc(sizeof(struct metric_expr)); > > if (!expr) { > > ret = -ENOMEM; > > + free(metric_events); > > break; > > } > > expr->metric_expr = eg->metric_expr; > > -- > > 2.17.1 > > > > -- > > - Arnaldo