Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1527236ybk; Thu, 21 May 2020 08:57:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD1yoZKkhiitOjTNIPfIIftn+fETLNN214G5Sl0TVMvyB6y7erPRwHv4crRmJsa+L7hB/j X-Received: by 2002:a17:906:645:: with SMTP id t5mr4402085ejb.412.1590076677015; Thu, 21 May 2020 08:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590076677; cv=none; d=google.com; s=arc-20160816; b=DY0l2niaIwMRWd1fu97ldFUEEEJslzsdsTKtiTCFP1pM2IpW3zGcclyzq1+z3MT+Ja 1lDC2tP6OG5NUNRI8oqGiAkGP0bHJXlyEjdxmjmg3JJJYZGBrK9piNfM2RGwbyOeY/1W /g1c8BFUA3hsLvysKqnGq145eweRWD/0DGobWi2TvmIJLfV7qX+yTwIW65SbsRL68Djr f+HycQUmx8OsBDDQD1HIKU6jm/QsNclmX9yNCRzVvCNhKIJe2egOFIFxIBubNsHFs/Pk CmzvZWA6MTF7BtWObcR/AX0JuV9WE/KVXRmA/qhTyijY6bAMr4KjpbC3AtwNAs3w+7ud BZPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=NlwlmHd/Paz+9EFTW4xliYlk/Hhu/73BhIVQMhmpnxA=; b=ZWYovzKiAonlQGpp7Oua7BzzWfTqqWc4t0j2c1MSxptQUMDI7tQdgc/9h2sHi3GMOw IfzVDr1T3H+yM15XKwFUf39HfUfRvrI2fEkb2Lk9mTkSyA/aWW6cXAsE+YlzoKciIYzS 34fsjCtsmvwN/Pn/JuBggzxTLoDdpnyPkK636VtXvkRf6qIxNOth1pUHAkx9NHIcO5cD c6kxe8yyNcTM5cqOQQ8BdkNjN3d1vChtSgxUt8k7biT5inZ+zKxC0CIl5V48h033g1dt 3A+Zm1JF74560uwwtSlbGQ2JXyf+PCXaQs6t9irA7LePWzA508ZYCmkZjhK7Gi9DuRUy jCgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I0jYgn73; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw9si3341040ejb.476.2020.05.21.08.57.34; Thu, 21 May 2020 08:57:57 -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=@kernel.org header.s=default header.b=I0jYgn73; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728649AbgEUPyE (ORCPT + 99 others); Thu, 21 May 2020 11:54:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:42998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728295AbgEUPyE (ORCPT ); Thu, 21 May 2020 11:54:04 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 61828206F6; Thu, 21 May 2020 15:54:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590076443; bh=TKWRFarh/DR/G+dyqD24vZ5+B4+IDBEfETfLPpR5GC4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I0jYgn73mDBEa820iMQpAo4MjQC+FGRPpOjEOaFRwbXq0f1dN+WI8MsKLaYbgF7cQ NcrhhAAU+P+iI4xcIanYFO1r4Vg3S0ZfJgeWveLLzdoATSJRKrhCsgU34Qtyy2EH+t 7UyxvJRHd9oWXFnF2HA50KDgcUcbnvCqrdMbYb9w= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 7197D40AFD; Thu, 21 May 2020 12:54:00 -0300 (-03) Date: Thu, 21 May 2020 12:54:00 -0300 From: Arnaldo Carvalho de Melo To: Wei Li , Ian Rogers Cc: Alexander Shishkin , Jiri Olsa , Mark Rutland , Namhyung Kim , linux-kernel@vger.kernel.org, Li Bin , Xie XiuQi , Hongbo Yao Subject: Re: [PATCH 1/4] perf metrictroup: Fix memory leak of metric_events Message-ID: <20200521155400.GA14034@kernel.org> References: <20200521133218.30150-1-liwei391@huawei.com> <20200521133218.30150-2-liwei391@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200521133218.30150-2-liwei391@huawei.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > 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