Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp873691pxk; Thu, 17 Sep 2020 19:57:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH1nK9lAmlqjN1LNLmmB4fSm+eu97PYmSzcF/jUEqC1sejH7svYtj+rObEtLW36Z9Gpl7f X-Received: by 2002:a17:906:29ca:: with SMTP id y10mr33154852eje.327.1600397830088; Thu, 17 Sep 2020 19:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600397830; cv=none; d=google.com; s=arc-20160816; b=et8FwjHZxGboN/cG4Ni5nx8rHPJhqQBTHlPQTL/TFa9ybqA+r2q5Hu161FC0YsuzqV zeMq/rjjGgiiSY2H/MuCx7AzpsckScozWZeI+M721fS6qJAtm8Of4eTY5b1mzZp32+c1 hPcUXjTlnT/U8h0RxwwpGJSmNNN3XvyidpC+I/knxAJ+ErRtZohEw5BmZuplXyEURv8x 5aYqC0cFFy/g0bgAmLRGRt/djEPS6q1a/03FoS1lLa2XV9MwU0WFCKcfx3MP+khkrzww b6H+8rwpqfhSqmYkJpcOzDxI5CTIZdl+N2mbkmL/S7DQO/diq7TE0s8XlSs+nmWWYIdz OfFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AxnKVjSylAGRTXAbuZ+dgQ+aUD3KOT3NTFmJgE+f43U=; b=uj9H/+gE+4sCTBBt84+9gfhFrYSH5e4OVfjTA35NYz2dxhf+S3z+54xG3QoiFJ8AsZ fE+1RdHK8SXS0VvqlidYqRz8TkTMAeJKRdQyGmfGzQFTDy+3Tn8tUersVYiDgJW+lDsk USVWuymxjhSipuHnETu8YZAkgz0beXAeXyhihuf8Rwvcbo/Nnl7rmKQo2qFf0QKLPe4g F/BtnDQG3j3x7qzMJoQPEqoEyiYrS/HaGZDNcky6DWGe0KdO0X+4+4cw8hWKnzFry+1K ky1HRLhcLJd67C1hNhTNpkGBtyrkAOLM1dUa1o6fBW2ZMWfYcSqFdvHyDc24vSmqwgEn yf7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AJR+uXWi; 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 a1si1165429edy.292.2020.09.17.19.56.47; Thu, 17 Sep 2020 19:57:10 -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=AJR+uXWi; 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 S1728611AbgIRCy4 (ORCPT + 99 others); Thu, 17 Sep 2020 22:54:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:57464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727902AbgIRCHS (ORCPT ); Thu, 17 Sep 2020 22:07:18 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A20DF23888; Fri, 18 Sep 2020 02:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394837; bh=uPu3azdMyxArLR0MygGlpcIAE+zcq00+IfHIF4qjxpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AJR+uXWi6EOF6ctkHz/+jDw5GIzLmwVXqpsqFD25uLy66ib3cFclk3K4Rm7Vr29S8 wxJLXg2xhUJiFeD4FVCWczHHbncpfbLkcq7HgflZEazg1NT2ohw7MWYtn7tf7o0pbf Svr6O5yM9ZgRcGUCAXJo5ngGQNRkKp/4/H76lM14= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ian Rogers , Alexander Shishkin , Alexei Starovoitov , Andi Kleen , Andrii Nakryiko , Cong Wang , Daniel Borkmann , Jin Yao , Jiri Olsa , John Fastabend , John Garry , Kajol Jain , Kan Liang , Kim Phillips , Mark Rutland , Martin KaFai Lau , Namhyung Kim , Peter Zijlstra , Song Liu , Stephane Eranian , Vince Weaver , Yonghong Song , bpf@vger.kernel.org, kp singh , netdev@vger.kernel.org, Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL 5.4 296/330] perf metricgroup: Free metric_events on error Date: Thu, 17 Sep 2020 22:00:36 -0400 Message-Id: <20200918020110.2063155-296-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ian Rogers [ Upstream commit a159e2fe89b4d1f9fb54b0ae418b961e239bf617 ] Avoid a simple memory leak. Signed-off-by: Ian Rogers Cc: Alexander Shishkin Cc: Alexei Starovoitov Cc: Andi Kleen Cc: Andrii Nakryiko Cc: Cong Wang Cc: Daniel Borkmann Cc: Jin Yao Cc: Jiri Olsa Cc: John Fastabend Cc: John Garry Cc: Kajol Jain Cc: Kan Liang Cc: Kim Phillips Cc: Mark Rutland Cc: Martin KaFai Lau Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: Stephane Eranian Cc: Vince Weaver Cc: Yonghong Song Cc: bpf@vger.kernel.org Cc: kp singh Cc: netdev@vger.kernel.org Link: http://lore.kernel.org/lkml/20200508053629.210324-10-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- 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 940a6e7a68549..7753c3091478a 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -174,6 +174,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++) @@ -181,11 +182,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.25.1