Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3864813ybg; Sun, 20 Oct 2019 23:27:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwky+oFauf+4SIIY62L/eImRiyAQh6XOhcQSFCGoUfLfLuIdSWE1hm2L6A9383/HbUE08BH X-Received: by 2002:a17:906:f110:: with SMTP id gv16mr20951707ejb.331.1571639271554; Sun, 20 Oct 2019 23:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571639271; cv=none; d=google.com; s=arc-20160816; b=FSCLHYTKboIYnelnAFxb0XnAJQftfBwLeWbebvF/i4dzuShUFAbleq7DOql6PAvYC6 a7yqVQTtBXnFZzKLJ1ustO9SXqP67D/6D0zN6Gu8F6/oUk2CJiNtOvCKNy6ck7oCdAdU cdgIwz5PjD6isVG4HoDfvLuotuk18SmNE7VGUxbXTzu63LkDxk8Tav5VoB9fjf/iRwFP Pqg/tB4QBvtzrvmFEECcAFtZFLfH5Ng3LD3iJorwi0kLkORjgf/nNfdiIhuc/Y3thsL1 A/LMyascWYxejZH/hzH575byRgAxjIh6n7WkFDMrPDpGhYx0fgkIVBpn7kOsRv6FA5xi Hjyg== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=BmJ4+MVNO21AkK67r7pvpZfZUMNTDXCp1xXOD6xJwxU=; b=qY7lFn6bxA9I3qHdcUVz2HfEtMetOj7B/HITZRC1/Z1ZWv9e+RGwap3y+w3e93cZGq JMDWs+qygs5Pg27+teRjTKUuZhnGt+gwQEigcTEZ3JgLKc1NZUB5nCT6JOWckqTqgI3p hI0Muv27Nh2Aqp3G/dQtQ7RyG4rQqLG6q66yQ2it3S0Vh8Qa9HoXx2RaO2KsMwtzofg8 U7hwG0ilw8Ytgx46fPfmOBzQIA2mnQSjWlTR4zbrJcxmsxMQYqTVo0SO5DGZvh/K3i5h 7JMpxa/ydNyBnXUX2RxJ6subNOk4nq6Ru/dyqI2pMGLhUKgBWukkI+trc9+0dvIvDS1w DxuA== ARC-Authentication-Results: i=1; mx.google.com; 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 z7si8130359ejr.99.2019.10.20.23.27.28; Sun, 20 Oct 2019 23:27:51 -0700 (PDT) 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; 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 S1727287AbfJUG1L (ORCPT + 99 others); Mon, 21 Oct 2019 02:27:11 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:33236 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbfJUG06 (ORCPT ); Mon, 21 Oct 2019 02:26:58 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iMR9P-00025u-58; Mon, 21 Oct 2019 08:26:43 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 84F971C0092; Mon, 21 Oct 2019 08:26:42 +0200 (CEST) Date: Mon, 21 Oct 2019 06:26:42 -0000 From: "tip-bot2 for Yunfeng Ye" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf c2c: Fix memory leak in build_cl_output() Cc: Yunfeng Ye , Jiri Olsa , Alexander Shishkin , Feilong Lin , Hu Shiyuan , Mark Rutland , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <4d3c0178-5482-c313-98e1-f82090d2d456@huawei.com> References: <4d3c0178-5482-c313-98e1-f82090d2d456@huawei.com> MIME-Version: 1.0 Message-ID: <157163920230.29376.8676818856135975024.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/urgent branch of tip: Commit-ID: ae199c580da1754a2b051321eeb76d6dacd8707b Gitweb: https://git.kernel.org/tip/ae199c580da1754a2b051321eeb76d6dacd8707b Author: Yunfeng Ye AuthorDate: Tue, 15 Oct 2019 10:54:14 +08:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Tue, 15 Oct 2019 12:08:13 -03:00 perf c2c: Fix memory leak in build_cl_output() There is a memory leak problem in the failure paths of build_cl_output(), so fix it. Signed-off-by: Yunfeng Ye Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Feilong Lin Cc: Hu Shiyuan Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/4d3c0178-5482-c313-98e1-f82090d2d456@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-c2c.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 3542b6a..e69f449 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -2635,6 +2635,7 @@ static int build_cl_output(char *cl_sort, bool no_source) bool add_sym = false; bool add_dso = false; bool add_src = false; + int ret = 0; if (!buf) return -ENOMEM; @@ -2653,7 +2654,8 @@ static int build_cl_output(char *cl_sort, bool no_source) add_dso = true; } else if (strcmp(tok, "offset")) { pr_err("unrecognized sort token: %s\n", tok); - return -EINVAL; + ret = -EINVAL; + goto err; } } @@ -2676,13 +2678,15 @@ static int build_cl_output(char *cl_sort, bool no_source) add_sym ? "symbol," : "", add_dso ? "dso," : "", add_src ? "cl_srcline," : "", - "node") < 0) - return -ENOMEM; + "node") < 0) { + ret = -ENOMEM; + goto err; + } c2c.show_src = add_src; - +err: free(buf); - return 0; + return ret; } static int setup_coalesce(const char *coalesce, bool no_source)