Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1422236ybk; Thu, 21 May 2020 06:35:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb0ylAD//8wMBmQ2K6mvQDTJ1YduAvtJnS/MK9GHHzN4uGlmCeiCcI5NNv31PDQR8t9GQm X-Received: by 2002:a17:906:6411:: with SMTP id d17mr3450868ejm.109.1590068114914; Thu, 21 May 2020 06:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590068114; cv=none; d=google.com; s=arc-20160816; b=Xow5HBb+/w+7p9330CQE9pw//q7sQx9iQxGABcZ4mDit5tmyI/SEcqf5BGSTMocBOe 2Hp2AxM0jK6RvA/iiDiUJDhdPyg8tQrTqnTpemseBK6P78kszPb8h5ho3K600g+EyX5n K3CKqRzbpVqX7B+0HTbgvymB2a1BRK8+lqRWJmJqtrfszE0rXiAs9UqYc5Y2ZCZFjwix 3wRAG3iuNnqGZsdU3M8fixc0Tq5Zc9PIUXQHszl9NhGj+KEPATkJOWulCSBjs4khJ6nr xfX0Tmm0uVzlyeBiqFdjPLWcNguTc0vLgOop5aLf84cRfvTnpaGr8vNzsquhzcR3jG1Q Gfrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=DhJM4EbzwiG+PDuG7gAIMjGbOuVU/N+uAt7DLeUtZpM=; b=xn4HLzH4qqnJhE3G9GV/OqQyiX7fMtxhO80MucJ4Zhsvd7Y1tVwtvlHJMdhkbbTuOU 9up95LKcqq6EwT4jELtOml/n5KFr90Tffs9tpcEJ2D1cYDddZOxMjHnUx+Rjr4/pQpMY 5uBXbi0vq/GwHDYH/xpunRncZeqILKGyX8ezhtLqGptGOwj0G50il3uDZvycD9CQvO9i rscvklKtC5Yvhnu79qlGfX5/WEkcAF5pI3rnrWBN5/FFJp7QnrXP5m28uyz1HYcX/k8T l0dtw/4FsqKe4dy/AyPG7lZGx2N2icXQF+Or8o1BQbELHY+iUvv0GbuYdrLZ1BgwgkcD lEjQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j4si2957527ejy.312.2020.05.21.06.34.52; Thu, 21 May 2020 06:35:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729197AbgEUNdL (ORCPT + 99 others); Thu, 21 May 2020 09:33:11 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4878 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729402AbgEUNdL (ORCPT ); Thu, 21 May 2020 09:33:11 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D1167AE647989BB738AD; Thu, 21 May 2020 21:33:03 +0800 (CST) Received: from euler.huawei.com (10.175.124.27) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Thu, 21 May 2020 21:32:56 +0800 From: Wei Li To: Alexander Shishkin , "Arnaldo Carvalho de Melo" , Jiri Olsa , Mark Rutland , Namhyung Kim CC: , Li Bin , "Xie XiuQi" , Hongbo Yao Subject: [PATCH 1/4] perf metrictroup: Fix memory leak of metric_events Date: Thu, 21 May 2020 21:32:15 +0800 Message-ID: <20200521133218.30150-2-liwei391@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200521133218.30150-1-liwei391@huawei.com> References: <20200521133218.30150-1-liwei391@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hongbo Yao Fix memory leak of metric_events in function metricgroup__setup_events() Signed-off-by: Hongbo Yao --- 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 926449a7cdbf..69bf0f4d646e 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -184,6 +184,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++) @@ -191,11 +192,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.17.1