Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp896772yba; Thu, 18 Apr 2019 11:23:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxH/KmYGWwgQRl222ZHxx01cBjZhhdpWJXwbPnYqB6L2ucb52bmcuN0RMELcf/+5SCRXuZE X-Received: by 2002:a63:fd08:: with SMTP id d8mr2008024pgh.141.1555611825351; Thu, 18 Apr 2019 11:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611825; cv=none; d=google.com; s=arc-20160816; b=GCglkAEPOC2uirekVvgQSafgy4jjcfpV3LtOFMrWdBjnrlme42tPtjUPP9TS+ZllT4 /ixSv29rSpydrCTPRCyCVbXqcIsGF06hWVOlPmVKon30zqgqsHfbueZ8tbkXXHhluVU6 cyOlTw6UAAEeEj0tw2DQ+kdNSfjg5ZPI2ZSQWwN3L2bEGYUviMFrrMArkGSR82DsENFI qvp4uKwzEhzWsIzSj/pk/nzgPtyX5HlEvcKj8E0QN6jr9DMZ85D2lUOCoQTWQhfgzJhk 7w6+mV49zlGioD7SQSvuCbHQX+m0bHVydguwBrF0YqUQ8gYa+lwX3PbZKw2zzs47jj6T hB9Q== 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=ZqT+JNi4XP2XZlLJDtl3pEHoLQ/e3uUaTxOwZHV1aSQ=; b=gW0OqLskPmlY8QsUl0/MKoarXgo5xKss1TH88UMGxUYC3trbSnnr4acUOA1V0ysxlk vJjnn22OV+LdZIrfK0pryTC0ALZMS6LwcLVAn5GG7jPU3brLiPWcjK9BGEuDQ52T1LFo xTBO1xRfpaBWQCxHa7g8yZIPL3yFC8gzd0Gax+nz/vZAWU0CQiVS99EClBYMYxA9DX6Q r6HychGr7jr5lMWSXNMJzZB/v4Rl1s5166ADDxacAHItqXFK2Lv16cHpHyAPplc4MdeG Q95SYRAyUkmgpUaExzod+A38fCVfkGgGiA4lhOXnU/sY+mcch87xQ7Mhj9KNEaFf3H4o VWpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IHuPQRii; 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 i9si2972284pfr.111.2019.04.18.11.23.30; Thu, 18 Apr 2019 11:23:45 -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=IHuPQRii; 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 S2391849AbfDRSVx (ORCPT + 99 others); Thu, 18 Apr 2019 14:21:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:37838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403828AbfDRSHa (ORCPT ); Thu, 18 Apr 2019 14:07:30 -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 08B1C217FA; Thu, 18 Apr 2019 18:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610849; bh=J6zHWtH2ffHluELyz2CaIOneaIwVn1f4QVjA7sUZuys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IHuPQRiigj0pPXj1DA1l1+Q8aGNeA9pGR0cBXnHHyp3Sr1U0IHOMBahDH7qQ06SZK d2JIy6qwltd98XjR1NbH/Ws88Jqu0NbFL9oOhTHNLWmuzjdqxnuPIpDIzSOOP7DTU8 Xi747p+Q/Sw7h+v1kW41ebCnk8P34wH1E0jv6t48= 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 4.9 15/50] perf build-id: Fix memory leak in print_sdt_events() Date: Thu, 18 Apr 2019 19:57:26 +0200 Message-Id: <20190418160424.567934274@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160422.455656724@linuxfoundation.org> References: <20190418160422.455656724@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 993ef2762508..32aab95e1459 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -176,6 +176,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 14f111a10650..6193be6d7639 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2104,6 +2104,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