Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1357327ybj; Thu, 7 May 2020 22:39:52 -0700 (PDT) X-Google-Smtp-Source: APiQypLKeNX7xp4Iiv9vWyJOxJFC0k9VmtwArBA14++2ybwcpLNGqLqc62n+x1ggpel+KcYLJhjM X-Received: by 2002:a17:906:84f:: with SMTP id f15mr448263ejd.256.1588916391947; Thu, 07 May 2020 22:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588916391; cv=none; d=google.com; s=arc-20160816; b=jJ7+PwVZBRZ+wQJd+cgP9wGocp5kmGZLxQ/wLgZgivQ4LAdezzNnJkhVfVCI9sbAYj pX9PUzkiG7mAPq5osdD3ywI4PzKLw5KvB4cjgcjRtu0Y6HUfUvb62PWeGpt9qAjN2n9y gppvtuzmVfTWdGzOlAtBdpMTUo49Vn3DhX7bq4PGqvIwOzaY1+rBCg5tC1hYliecfq7A axIsk8riPa88bmTWwZMy+f9DuxxZ4MYw6/gRqjpqVNHRGowQOiOG0OLHmbtmBIAgSHc2 177KTSk+RKmiDUnPjRKThPSMaCua25VQ9+UMgpTkUbpHovOtckp0hLXP/MJzJnpfc6bN m1NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=m8WpKXu2V+9NqkR5jp5ATN8K2H0ocf3aE3is59DK73Y=; b=oa03gllR2vyXUl19CUHpQi7YYRx47tz537TAC/HN5QjQPepkWaS+dQlPKo4VcpI/nh FRrcDL1yrXO+Wilc4KpyuImfAs4DT3XvNTc4MPmO0PIHBFf1VwORtPU71yExvaxp4kiL cYqjFPAKhNmPijn5/jvlnQ8wa+pc9B4PGuTQISnJ5E9V5+cTYH3V9P4yACqLJehjMehg pHT+Hy6tgUkXy6IMucfeqIEjWN1/bDaHMnOhQziYBMehoj9qIaL5O32lN+I+K/X/cg/W jGVsa9EABzAY61ATYVlk3qlBSyqNCC6gS6uvF6HCy6oNvLyZ9haOoyB+q1H9E50995Ea WGMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UREL49hi; 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 u20si374625eda.9.2020.05.07.22.39.29; Thu, 07 May 2020 22:39:51 -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=UREL49hi; 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 S1727932AbgEHFhh (ORCPT + 99 others); Fri, 8 May 2020 01:37:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727123AbgEHFgv (ORCPT ); Fri, 8 May 2020 01:36:51 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A5A0C05BD0A for ; Thu, 7 May 2020 22:36:51 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id p126so859487qke.8 for ; Thu, 07 May 2020 22:36:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=m8WpKXu2V+9NqkR5jp5ATN8K2H0ocf3aE3is59DK73Y=; b=UREL49hiJMKQT0MfwJtSsvtarRZXQbdKzRdUjiKYFOqK7IONhA54ZD431jAbuWZnuj bTxCoCvWB40r0f5ojl0fRYliOvM6RphcZmnSoIHbfnL8zezBl4aJvDjWS79UevNBv8ev InnXkRF5ev8kUrvYha/fAOTirjp3erYPPtYa9HyVruMrCUzxEthOLzOPwg4hGkn8GfW6 ekC6metTeJMu3DZFzzeKioxEV7B34JMUjv6fJEh6KvHd628pj2rGeozGz5aRUfKWbCGe +4PlDnF1T4SZgKryW634bC3pJHSZLLCBYz5hOJaOFOB8lq5c9nJsVNteevqL7dKgtz7u GmZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=m8WpKXu2V+9NqkR5jp5ATN8K2H0ocf3aE3is59DK73Y=; b=aSwLGjSo1ojs3lQ9/RfSZvvSW4jd6RjwEjPY8HjEg6Gn60Zlok3M6Dr4Qvs/jh2W1r Nqq2NEloXDE07D0fw+NHqD6lrTugnwIX43yl2jXyzHBZ3RlMVHYwHKQ0OKs6S0l03FMx WnzRiTc41NlZEp7+EH+2j+DvoQm+1bxVOvSEcjUc6p9SEwGuf41kCj+rNuVEGUjK7Lr/ F+JsOiht+xCb4ufPP4e7zVnOOJBg07bGACSFPAh/j8oZE5HPw2xay8ua9bSEaj3Bn0PW uD7urn6RBVtKm0KC5YI8/MxVMdENQdT6lYQ6df22+ljDPC4oaNNmg7CV8HSjl/l4cujs H5UA== X-Gm-Message-State: AGi0PuYU9nTx2LWiakdPpmpbYiY7o6Fksi+EDfg8iCvsxI0aU85gxmJ0 a7OWtEHsj4D6GeWJ+q0517gClw+nslbf X-Received: by 2002:a0c:f70c:: with SMTP id w12mr1112683qvn.28.1588916210193; Thu, 07 May 2020 22:36:50 -0700 (PDT) Date: Thu, 7 May 2020 22:36:24 -0700 In-Reply-To: <20200508053629.210324-1-irogers@google.com> Message-Id: <20200508053629.210324-10-irogers@google.com> Mime-Version: 1.0 References: <20200508053629.210324-1-irogers@google.com> X-Mailer: git-send-email 2.26.2.645.ge9eca65c58-goog Subject: [RFC PATCH v3 09/14] perf metricgroup: free metric_events on error From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , 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 Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, Vince Weaver , Stephane Eranian , Ian Rogers 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 Avoid a simple memory leak. 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