Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp886551yba; Thu, 18 Apr 2019 11:12:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqziomb4u0Bu/Dr3Pxk5oEtmysXoVEARKYFrx3fgGLw9aifMoxiG0HfyBbvmL5hWjOzSYJ9T X-Received: by 2002:a17:902:8f92:: with SMTP id z18mr98780683plo.123.1555611164014; Thu, 18 Apr 2019 11:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611164; cv=none; d=google.com; s=arc-20160816; b=Y2WrS4pOiPJ04NPsxeZEqrv+yaGohLWYtNEQ1vmiOSRgAMZE0mUpKPNP3xb82IsfT1 oZQr7XcMh6erf5yVJruM5sVHKu635MmgtyU9YCpMfzuJbcApBa2BeLk4n/Dribbgp/8t FPDLB0ceXM4BxgcRpmhoD0iWzdUaAZCTDeQF9cNuwxJ8hkIz2ybYZwVamlqSjHBSbr1y i4oyH9R81foQwzkL1wdksHIFpwXW6cHZ4bQwIILiqkFRvzsbP9q/LLV27eCqexQrLex1 0vd5tbGUeABLHmWvdNdzzRqpu5GLiku3T3WwnLy6nAddK4UjN8gNefT9MvxczROiDh+m DVZg== 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=SGHTWd1M24dpthYfJd/X87laaTT3HVYtVtPpnIXg4sk=; b=ltfzUJqhBD3CxMIbIVblSRt6yqb6ntqVutHNfzlo2B96NwulK2H3I4F7Ld6ooyS7Ev NRDfe/Mb9zz44wSo7qjZ5079sPOQ8S22GxSBf8g2On0pWxMsT2yrumrgEXbsyXOuOfHz Bnr/rEm9ZD/o//LHkc2WgxudDaEJxjtM+EhfZaGD64vKLqoQtzTvNV4D6VOYPxz3NH6V bMpPHU4Uu/aS0FGNk4M/pylWGB0mKLmq7M5AQeJ/bIdbDuC+PUpOQD7GQzoCWT3h6/5u nMXpVilsfXsUmXfGv7Xq0rgupgFFwbFnL253FmxgxxtvuG5XsBuUap0IKSVnfWUITpcS 2JGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EJPhE4jR; 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 c144si3130753pfc.5.2019.04.18.11.12.29; Thu, 18 Apr 2019 11:12:43 -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=@kernel.org header.s=default header.b=EJPhE4jR; 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 S2404183AbfDRSKs (ORCPT + 99 others); Thu, 18 Apr 2019 14:10:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:42638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404164AbfDRSKo (ORCPT ); Thu, 18 Apr 2019 14:10:44 -0400 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 41B6721871; Thu, 18 Apr 2019 18:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611043; bh=4SMogTcUUiflbvjek8tthCX9GQyV2hMYu9fnvWjPiyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EJPhE4jR8NXz9msPYsLQMrklkORNIjUrAGFfsh3tvy+PZhS1vRcoEZ9q8kwdTQ77O 2GQvy/aMRTc2T5x/bkA8bMaTqfod3bYDbYhx1qoW6HkvxyTaw1JFZtH6Nlt4Lzcerr R+jrUurJ3qs7ztAyI/GR3CHjQ8QvzfaEJJ8Cb26A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Changbin Du , Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra , "Steven Rostedt (VMware)" , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.0 38/93] perf build-id: Fix memory leak in print_sdt_events() Date: Thu, 18 Apr 2019 19:57:16 +0200 Message-Id: <20190418160441.115021756@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@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 [ Upstream commit 8bde8516893da5a5fdf06121f74d11b52ab92df5 ] Detected with gcc's ASan: Direct leak of 4356 byte(s) in 120 object(s) allocated from: #0 0x7ff1a2b5a070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070) #1 0x55719aef4814 in build_id_cache__origname util/build-id.c:215 #2 0x55719af649b6 in print_sdt_events util/parse-events.c:2339 #3 0x55719af66272 in print_events util/parse-events.c:2542 #4 0x55719ad1ecaa in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58 #5 0x55719aec745d in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302 #6 0x55719aec7d1a in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354 #7 0x55719aec8184 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398 #8 0x55719aeca41a in main /home/changbin/work/linux/tools/perf/perf.c:520 #9 0x7ff1a07ae09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) Signed-off-by: Changbin Du Reviewed-by: Jiri Olsa Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Steven Rostedt (VMware) Fixes: 40218daea1db ("perf list: Show SDT and pre-cached events") Link: http://lkml.kernel.org/r/20190316080556.3075-7-changbin.du@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/build-id.c | 1 + tools/perf/util/parse-events.c | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 04b1d53e4bf9..1d352621bd48 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -183,6 +183,7 @@ char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size) return bf; } +/* The caller is responsible to free the returned buffer. */ char *build_id_cache__origname(const char *sbuild_id) { char *linkname; diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 9afd0d2beef5..03860313313c 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2342,6 +2342,7 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob, printf(" %-50s [%s]\n", buf, "SDT event"); free(buf); } + free(path); } else printf(" %-50s [%s]\n", nd->s, "SDT event"); if (nd2) { -- 2.19.1