From patchwork Tue Sep 29 11:00:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 289405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 801E9C4727F for ; Tue, 29 Sep 2020 12:22:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AEE42076B for ; Tue, 29 Sep 2020 12:22:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601382169; bh=1+bDAC057cRqevoqUn1yDT8QoWbfQBjWAA7gtYY30kk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=iMSr1zyL6zUGMTx8Xm19CkYSxWcwm4wYqxh0OUGBqg0C1DkXMFnu2FHFN65sLyw4a rnmF999wRcpBJQOJW6rukKrGRAKvZTpVSLPRNMm0JH/xrJkrxx+xY80Ks5o0teTT9V dMFysikJKxCS7d2OXcXHsyaBD0C2T89SX+Gd04fA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732568AbgI2MWg (ORCPT ); Tue, 29 Sep 2020 08:22:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:48452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729797AbgI2LfL (ORCPT ); Tue, 29 Sep 2020 07:35:11 -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 A683323C40; Tue, 29 Sep 2020 11:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378904; bh=1+bDAC057cRqevoqUn1yDT8QoWbfQBjWAA7gtYY30kk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eRSGQ1QpMAxoGQ1LejssabvHFZ4GLivTXSNNyV9lfeFY0kJp65KT8mcmgipUTPQTz 4o8prcnEwSMZ4uNI/Q2UJkdSm8mMmLaPeIGMptjo/y+wyKFLXF5111nctCE9+q+y00 mrMe8ltTjssKdikq8YD26Ke0CEYsPQra7/ygtU3Q= 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 4.19 182/245] perf metricgroup: Free metric_events on error Date: Tue, 29 Sep 2020 13:00:33 +0200 Message-Id: <20200929105955.829907379@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105946.978650816@linuxfoundation.org> References: <20200929105946.978650816@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@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 8b3dafe3fac3a..6dcc6e1182a54 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -171,6 +171,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++) @@ -178,11 +179,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;