From patchwork Tue Sep 29 11:00:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 11805687 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63079618 for ; Tue, 29 Sep 2020 11:43:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44DB1206F7 for ; Tue, 29 Sep 2020 11:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379798; bh=uPu3azdMyxArLR0MygGlpcIAE+zcq00+IfHIF4qjxpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZoVCMY9mBpPB1DtBx6jSRmwf//I5C+YgCvrAm5UMvrtx2K3A8PR1o6huYJiPhKDG7 qixTd7bmBN/1t2ho7zNH8PyMEHs/bjhwHzEzB9FIjYO3TgEVBrDH0naC+8TafarSUU GwRnEZg9gVCwwJ+1rbZuKEh1UGJwPqDQsEzCxZ48= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730769AbgI2LnR (ORCPT ); Tue, 29 Sep 2020 07:43:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:41126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730764AbgI2LnH (ORCPT ); Tue, 29 Sep 2020 07:43:07 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 602DE206E5; Tue, 29 Sep 2020 11:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379787; bh=uPu3azdMyxArLR0MygGlpcIAE+zcq00+IfHIF4qjxpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yGit3C0xSK7ED57Kh/JoL1KHSwZaGqEuzMlt1UNACz04Civ8gM74Xh2U0br7j6qLg YdvioUBCyrCjfsaPjfCFLEZK3sLs2oTvfUDNwAW3DpyvmrU9rxU95bodaOe8ZljzI2 RK6j2RhJzW3JGXnBW86ktRnMSOSVFflONzj2WMoc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, 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 5.4 287/388] perf metricgroup: Free metric_events on error Date: Tue, 29 Sep 2020 13:00:18 +0200 Message-Id: <20200929110024.351116677@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@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;