Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13475123ybl; Sun, 29 Dec 2019 12:48:13 -0800 (PST) X-Google-Smtp-Source: APXvYqwMsTWQMjEgGGHt3PeQ0Ve90SWaRAVzSZhOTcyysNj+srpbB/tTBo2i9nagndUqqjVaC/AB X-Received: by 2002:a9d:7e8c:: with SMTP id m12mr72389677otp.346.1577652492850; Sun, 29 Dec 2019 12:48:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652492; cv=none; d=google.com; s=arc-20160816; b=JeKTRdu23RtzoCDqBpsve3+bK+8zeCTXLHtILfxwFZvq4qy9WB/z2JMmloyP3OhIe/ a25i2S22ua9WrM9b2ntA+ECljP5VUf6AKcAsOmBQBPUcOnFRI9NSUL8s22LHwJ6fEP1m Js7D6/bBmsoI8NsqiA97JbM8Adrh9qqNFYNvi7Uts+TaIjPhu2w9ak5UfS46v8vC61fj 72RnlLnoGyG9Pn734iU724TGUrWhVb/sEeUIrWatjBKvYAJA4SJGf4Mu3i/fq8uYXpiX mqf3VxO2sjGQFgVGTnnEYLGr4lC71C68HroTR28fXoxCMGr9I2YrMkTrwcYVKQIUKy/j fwxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lpiDZUrWKlcFVCDNczj3lCkZ65EXdbJauDDpykar0PQ=; b=0R3tVf+V/7+NO+3rs3n1inGIRzT6mlnfBghMSJiukg64xoblYHxlkTlahejVFJGZRR RuVMH8sNkWfVuPARb07NCKXW4OuOkMItT1MxZrmMV3guEQBUZHYUQ+bODKRxhyCrsYw9 z3PF8RJQwjkLPESzTayhIhasncDDe8ctUOewRh5ndVYkFAsdEROM24/9PUsml/qkeOmM UpbO9bXCn1e3lJ2emFmK4Dcz8iCDXQdQXLbl/YYYeJOZblkhHZaz+DEDke5EYEcDybU/ gJojEt1z4yI0zYwHM4hn3THbxDAkUG10p3o/56F5oJHWWrJo04S8UMPVM9r5akn3BQcv iAaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BVVXO7oh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h22si18352182otk.18.2019.12.29.12.48.01; Sun, 29 Dec 2019 12:48:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BVVXO7oh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732161AbfL2Rvs (ORCPT + 99 others); Sun, 29 Dec 2019 12:51:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:37386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732146AbfL2Rvp (ORCPT ); Sun, 29 Dec 2019 12:51:45 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 CF47A207FF; Sun, 29 Dec 2019 17:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641904; bh=Wzwy2xJlxAlno0TwqjNdIp7sOH74/Dtoz4tgIgwYBA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BVVXO7ohVqroAkW6lOqGoW6nyFv20CYKkNW3fKdDhFkQnUHkszk9+tv3UG/4vMBNx S15YjKh+vKpJRXYGxO154qcMUER3j1Qt6DmSCjy7OUev6eIQbR43IeTlE/i81R3DWx kw0UcQKe3Tl8ezJzeM8NftIDZptx5bfOgwp/S4pY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Rogers , Jiri Olsa , Adrian Hunter , Alexander Shishkin , Alexei Starovoitov , Andi Kleen , Daniel Borkmann , Jin Yao , John Garry , Kan Liang , Mark Rutland , Martin KaFai Lau , Namhyung Kim , Peter Zijlstra , Song Liu , Stephane Eranian , Yonghong Song , bpf@vger.kernel.org, clang-built-linux@googlegroups.com, netdev@vger.kernel.org, Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 260/434] perf parse: If pmu configuration fails free terms Date: Sun, 29 Dec 2019 18:25:13 +0100 Message-Id: <20191229172719.205964752@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ian Rogers [ Upstream commit 38f2c4226e6bc3e8c41c318242821ba5dc825aba ] Avoid a memory leak when the configuration fails. Signed-off-by: Ian Rogers Acked-by: Jiri Olsa Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Alexei Starovoitov Cc: Andi Kleen Cc: Daniel Borkmann Cc: Jin Yao Cc: John Garry Cc: Kan Liang Cc: Mark Rutland Cc: Martin KaFai Lau Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: Stephane Eranian Cc: Yonghong Song Cc: bpf@vger.kernel.org Cc: clang-built-linux@googlegroups.com Cc: netdev@vger.kernel.org Link: http://lore.kernel.org/lkml/20191030223448.12930-9-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/parse-events.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index d5ea043d3fc4..422ad1888e74 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1365,8 +1365,15 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, if (get_config_terms(head_config, &config_terms)) return -ENOMEM; - if (perf_pmu__config(pmu, &attr, head_config, parse_state->error)) + if (perf_pmu__config(pmu, &attr, head_config, parse_state->error)) { + struct perf_evsel_config_term *pos, *tmp; + + list_for_each_entry_safe(pos, tmp, &config_terms, list) { + list_del_init(&pos->list); + free(pos); + } return -EINVAL; + } evsel = __add_event(list, &parse_state->idx, &attr, get_config_name(head_config), pmu, -- 2.20.1