Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1581828ybk; Thu, 21 May 2020 10:11:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv21yQLY3V5K3gyhBgjwEQk9ziEpwWdOC3oTDl8V7yCrUPYOt69sd1vE3e39RHpfWFYOw/ X-Received: by 2002:a17:906:bcf8:: with SMTP id op24mr4461245ejb.260.1590081060216; Thu, 21 May 2020 10:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590081060; cv=none; d=google.com; s=arc-20160816; b=jxAPsO5UnDW14CVWesT9mQMFt1bVbJUg6dLATIpCvExi00b31rSibBik+dlnyHfuyC 3ruKk8n1genYlC41mYT9PHyFNnThtMSlMMMggXpaZgC4Cs+dFVIe7GbtJWt6pjwmaD4g MMz1fRY5nOdp/waPsI5cgag4HbWnbcnVlm8gcy0KqdE1afEz7iKroUdTyc0v8Z3zuGrs W5h+O0CyY58ZxEDr5u/rnB0yOIuDb+jG9NdZ2TcJ9p2PZtUmMl2ZVeuOL5JUoifBJocv 3jmlHjVSjkmkTRlIGhJXUVP+opFeDqtWxBBBvwzTB0p9VMrb3WXc2Td/xAB0/s3vMHNo 4FRA== 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=C6fFO5yVmKr1W5aZ3b+7u6yTOoKipvTUd2elNneagk4=; b=yOmwSFKRv3VBnFlFFbATt1To6GmQ0ftD+c4qTs90BIHyx624cp3E8uG1h3jBRfYw01 OCijaFVzKk4fYT6S0ezR+eDzlMDhbkc3GYiUqIHhKV0FiYLFG9aopvZi+s4hL058BEpB lIASHzd3ftYgzKpamb6jypYrhW2SRkmdHc8L39k5I+4Zd3U9zO0vivxXnfGhQ58CrsDE xm1rsq5vahm6JDYLc01WiytYs2kiJ9SdPVQZXMz3URCyKxKsc4LdoWqNoJWYg4jOl8nM hVu3vW+eKTrNHVhKzjR+BBEtHMfgbZ5N67NZYFXO2MBVvuC3HYXhAxx5O2W5OZ1yo3j2 HVKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jX0v0Uwv; 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 d6si3552873ejm.185.2020.05.21.10.10.36; Thu, 21 May 2020 10:11:00 -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=jX0v0Uwv; 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 S1729787AbgEURHJ (ORCPT + 99 others); Thu, 21 May 2020 13:07:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:42254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728565AbgEURHH (ORCPT ); Thu, 21 May 2020 13:07:07 -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 E8D9820759; Thu, 21 May 2020 17:07:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590080827; bh=OtwlfFmNQgc80UjNIdcExbJwJxfb18Gjc2AQYQZ4KCA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jX0v0UwvZ+soIo2gh1lmoddPZuETI8kS51MBmggNIbQ9bOOYSEpLfGRMWUN8bwbeX MjIzR+Dhfv4VmR1xNymBIMekvXeOOoPzHgjCkp5s0Qv/BOCOf+BPxKLF3ai+Cfq/tn Peze1O6CrD7GOjqV+bpFAKppYK+iHzATNC65OtsY= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id DB22F40AFD; Thu, 21 May 2020 14:07:04 -0300 (-03) Date: Thu, 21 May 2020 14:07:04 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Kajol Jain , Andi Kleen , John Garry , Jin Yao , Kan Liang , Cong Wang , Kim Phillips , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, Vince Weaver , Stephane Eranian Subject: Re: [RFC PATCH v3 09/14] perf metricgroup: free metric_events on error Message-ID: <20200521170704.GC14034@kernel.org> References: <20200508053629.210324-1-irogers@google.com> <20200508053629.210324-10-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200508053629.210324-10-irogers@google.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 07, 2020 at 10:36:24PM -0700, Ian Rogers escreveu: > Avoid a simple memory leak. Thanks, applied. - Arnaldo > Signed-off-by: Ian Rogers > --- > 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 4f7e36bc49d9..7e1725d61c39 100644 > --- a/tools/perf/util/metricgroup.c > +++ b/tools/perf/util/metricgroup.c > @@ -186,6 +186,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; metric_events[i]; i++) > @@ -193,11 +194,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.26.2.645.ge9eca65c58-goog > -- - Arnaldo