Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6001348ybp; Tue, 15 Oct 2019 08:11:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyp9W2EUAWar57XAArLiK2HB4hYtDCx8hCaLaY/wA0D2TEPAulN+MZnP0KFbbZOna70Ur5I X-Received: by 2002:a17:906:4d44:: with SMTP id b4mr36186417ejv.105.1571152286382; Tue, 15 Oct 2019 08:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571152286; cv=none; d=google.com; s=arc-20160816; b=uzmLkTwhRmeof4FaVbhSXY+TB1VylSk1S0DPnWkHeGy8oC19IS0eBxyQPUKBUnA4Il SW/7WZqw26C4In9RcFzit9qgcLfXoY8OWXMk9HQMQiILQ/oFJweCoIJ2pML0OznIsQxo lr3F1rTe2nemuhVZPQEPW2p47MF4hZfP/3Z0uBwceWYGWP4WqTumou3HJhKBwTOm4+Kd X8SkDcKSvB+4gtQfypNN3kyEdcz7ttw2iM8HWDMIbAKFgqkeZ3QbB1BypenrDmBwjH2V qjA+XtLcXMI4O0HFOQkLJ1TmYbu1UScrWllO5MtTMYnFAThg9lwXK8eSUp7mcO40plf0 JZkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=1FpMq7EcpHQR8/pfyktJU1Qq9chq6W6jLbp0yLXRsZA=; b=qXAMw1FoOUAJqqFUZuTFyiH420BFwilSiMyIRx3tjgcuoxE+g+rdtXBvD+BuRi05Ks 4b5/bHM9mzItXGUHMaM0gxV8+SUmkfI22XJIBfJDPbU1iXLNOTVYe2z52FPdIBA76Pjy k6wAEKQobKMiYPRdDFg9yZQaMGgynofAED+L9iFaeKhOoiVoBF6iTIhP7X8jZ79P35cs fro+YOMO3TgwJrRA2Nm9HH8Vh+lhZw3IfQJ9wociGP/zcz3o2Gi9jj6cnbGMUZ58vprC saTdoyiSioWCzbEAfqrQd9CUoX2G945l3ypKQ2HhZps76v58sbSe3fvo6Fjcm59GfuLl OXRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sedLu2UB; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13si13554840edy.320.2019.10.15.08.11.00; Tue, 15 Oct 2019 08:11:26 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sedLu2UB; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733269AbfJOPIp (ORCPT + 99 others); Tue, 15 Oct 2019 11:08:45 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:44209 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726523AbfJOPIo (ORCPT ); Tue, 15 Oct 2019 11:08:44 -0400 Received: by mail-qt1-f195.google.com with SMTP id u40so30986270qth.11 for ; Tue, 15 Oct 2019 08:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1FpMq7EcpHQR8/pfyktJU1Qq9chq6W6jLbp0yLXRsZA=; b=sedLu2UBGJ7f1OMvFaIVKNIIMbVzxtl8LH1lBiFpdk/HJuxAG6hk5Pi4aVqsgA5xz3 0SCJkcKtBB7bmEx5fQr1nCoSfnQ7/8MSYAMEPf+K6uG5Xdp7laU9OHH9/b2jrYQHKp+9 jxBryafS+ajBO3x51OiZKxW+t8LMHedL0oodpKrnhDVrx0RYGT+td9mdFVYZMm0PIZtq l6HcZksYu/YSWFWzl4mMfvypMeFx0KR99mJnw68PKcQ/rFawaO8DqAx4akqUa3igVRXG C3DS94RRMtoSc3ZUJf3Asg4YWKmy+F/Adga4RZi6q4WccS8+jOx/HOJoy7NgdqGT2CBr 2YKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1FpMq7EcpHQR8/pfyktJU1Qq9chq6W6jLbp0yLXRsZA=; b=NcdYJ5RYV4mrpm8i/mfSnsKT7HOexhBU1q0wi6ro/ypJoIHwIDAFwAuEpdyGTjkUms aaWoFkEzFWPzOwbzjuJp2bahtTA7Fb2m0f4cxusOfliOdBkNx63stpZ/QrqqfmefEbLa yQeV9poNnhyJy/ZO+D0YdsJ3N9bzFN5z7KO3kTBXxRKAOwY8c9K325Pc0QiAG+TMv2sM Y8MepARkq1kpKiSuofMbwYSyx7XMhAAer21n3ru9u3+ZL1IVMweffKyAaYYqRjhXI4YY kPEcarxOJ/3x0CLCw4u7R9Kk9DC2xe5w9u31HTBczkunfr5z9OA/ayGEdYLGdCZ82fiA supg== X-Gm-Message-State: APjAAAVqyH7QGHwBKhESCejnMr3NJVnM6CEUFgI6QneA5zOL3xSDK7MJ yP2ikM0jBVrvj9+EJMuOnBM= X-Received: by 2002:ac8:234e:: with SMTP id b14mr39917731qtb.346.1571152122373; Tue, 15 Oct 2019 08:08:42 -0700 (PDT) Received: from quaco.ghostprotocols.net ([179.97.35.50]) by smtp.gmail.com with ESMTPSA id q6sm9491704qkj.108.2019.10.15.08.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 08:08:41 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id BC07A4DD66; Tue, 15 Oct 2019 12:08:39 -0300 (-03) Date: Tue, 15 Oct 2019 12:08:39 -0300 To: Jiri Olsa Cc: Yunfeng Ye , peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, hushiyuan@huawei.com, linfeilong@huawei.com Subject: Re: [PATCH] perf c2c: fix memory leak in build_cl_output() Message-ID: <20191015150839.GC25820@kernel.org> References: <4d3c0178-5482-c313-98e1-f82090d2d456@huawei.com> <20191015084753.GD10951@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191015084753.GD10951@krava> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Oct 15, 2019 at 10:47:53AM +0200, Jiri Olsa escreveu: > On Tue, Oct 15, 2019 at 10:54:14AM +0800, Yunfeng Ye wrote: > > 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 Thanks, applied to perf/urgent. - Arnaldo > thanks, > jirka > > > --- > > 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) > > -- > > 2.7.4.3 > > -- - Arnaldo