Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp879358yba; Thu, 18 Apr 2019 11:06:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyGvh4Mg4znk6jyumDcSzwX41D9WWV/LtujskUmdeDof7lTf0hGu2NjbIdKtCL69z8E/i/ X-Received: by 2002:a63:87c1:: with SMTP id i184mr90848363pge.265.1555610766675; Thu, 18 Apr 2019 11:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555610766; cv=none; d=google.com; s=arc-20160816; b=FPvj3OjPb3iwOIgbUOa2+tOu51ZAgKR2vU1l6jQ9aiOUlz9y8QExaZkDyzxTPD95hy WOFpHIRLQ3TtIvelqymtw+/DS/UCRCFu94mzGX77txoDtgrT66+Fde4z0NIdH5aIGTcw 4+8YTcJednLlkREGcP2L0GpEyZSGJq3GpBgnSMBRvLCxG3mbzLll6I+Fj+d4ZFyASElC rrkyJapNFO8VYcp0yyO6Cvmup/EipBs426nonA9XR9nUjuCchsTxWxqNJQxyhZPfFGw6 tfTf4N6JkeAEvBp54CfQy5uNomwPNPFJjXcxspcDnm4k/P1KtumKJFw7uQD2CI33xq9k GA8A== 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=CryAUcLnK32PVSLZKH5MNZwqihX3kjUTVwrnIUSyDvc=; b=U6GI77I7/eZJNXkqS+HmJge7PumVN/kKPKhvhjzKh5fpKqJKMiuV+5SWLLt7UljQiY o4+a+V3Hd9A0kb4nr0RSk9u1B5Imn5kjVunlHwJpTHPpiKI5een4hp9Y/z6zIpU6naR9 avlwat1kw8V3JnRWAo7blfVq7Mcy5rwqMK/K94zX1s64U9xD5MW3gNS2w/8fAXQ2WT5Q Mq9UcyHoKj/NVagG680KT3umYPkYUwLe8umTWo1IRa/LgUw9xKZ3cf38G4Qm44WT14fa EteV6dHXK3kUJx1JMa21fvMFSn6V8dXyIE+QNsgomzkUc7X2DbljtMOXv28FTzsRTDn+ 9BjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZvHujiCT; 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 s83si2477324pgs.420.2019.04.18.11.05.51; Thu, 18 Apr 2019 11:06:06 -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=ZvHujiCT; 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 S2391033AbfDRSD7 (ORCPT + 99 others); Thu, 18 Apr 2019 14:03:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:60890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390372AbfDRSD5 (ORCPT ); Thu, 18 Apr 2019 14:03:57 -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 33C6B218DA; Thu, 18 Apr 2019 18:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610636; bh=8CzWUeKtUcPswHH92QLruB5Kir/LKdvIjLgzGnjZRRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZvHujiCT82qMe+0eDg3MwAOXEWvP8HRpEour4xufU3JeLo7bco4IVBWBKYRTC8hHh Oo3+pVNlj95b+4KxolyoZhTHIDRWa01k1/1sS4gzE5Xvg0VN5B5Wj2OnIQtJHRMVdG JjtT9arrf5gcs5TTC5M5imHOwS2qMrDxVgPNGuMU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Changbin Du , Alexei Starovoitov , Daniel Borkmann , Jiri Olsa , Namhyung Kim , Peter Zijlstra , "Steven Rostedt (VMware)" , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.14 26/92] perf evsel: Free evsel->counts in perf_evsel__exit() Date: Thu, 18 Apr 2019 19:56:44 +0200 Message-Id: <20190418160432.728603111@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160430.325165109@linuxfoundation.org> References: <20190418160430.325165109@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 42dfa451d825a2ad15793c476f73e7bbc0f9d312 ] Using gcc's ASan, Changbin reports: ================================================================= ==7494==ERROR: LeakSanitizer: detected memory leaks Direct leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f0333a89138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138) #1 0x5625e5330a5e in zalloc util/util.h:23 #2 0x5625e5330a9b in perf_counts__new util/counts.c:10 #3 0x5625e5330ca0 in perf_evsel__alloc_counts util/counts.c:47 #4 0x5625e520d8e5 in __perf_evsel__read_on_cpu util/evsel.c:1505 #5 0x5625e517a985 in perf_evsel__read_on_cpu /home/work/linux/tools/perf/util/evsel.h:347 #6 0x5625e517ad1a in test__openat_syscall_event tests/openat-syscall.c:47 #7 0x5625e51528e6 in run_test tests/builtin-test.c:358 #8 0x5625e5152baf in test_and_print tests/builtin-test.c:388 #9 0x5625e51543fe in __cmd_test tests/builtin-test.c:583 #10 0x5625e515572f in cmd_test tests/builtin-test.c:722 #11 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302 #12 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354 #13 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398 #14 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520 #15 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) Indirect leak of 72 byte(s) in 1 object(s) allocated from: #0 0x7f0333a89138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138) #1 0x5625e532560d in zalloc util/util.h:23 #2 0x5625e532566b in xyarray__new util/xyarray.c:10 #3 0x5625e5330aba in perf_counts__new util/counts.c:15 #4 0x5625e5330ca0 in perf_evsel__alloc_counts util/counts.c:47 #5 0x5625e520d8e5 in __perf_evsel__read_on_cpu util/evsel.c:1505 #6 0x5625e517a985 in perf_evsel__read_on_cpu /home/work/linux/tools/perf/util/evsel.h:347 #7 0x5625e517ad1a in test__openat_syscall_event tests/openat-syscall.c:47 #8 0x5625e51528e6 in run_test tests/builtin-test.c:358 #9 0x5625e5152baf in test_and_print tests/builtin-test.c:388 #10 0x5625e51543fe in __cmd_test tests/builtin-test.c:583 #11 0x5625e515572f in cmd_test tests/builtin-test.c:722 #12 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302 #13 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354 #14 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398 #15 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520 #16 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) His patch took care of evsel->prev_raw_counts, but the above backtraces are about evsel->counts, so fix that instead. Reported-by: Changbin Du Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Steven Rostedt (VMware) Link: https://lkml.kernel.org/n/tip-hd1x13g59f0nuhe4anxhsmfp@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/evsel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 44c2f62b47a3..0cf6f537f980 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1229,6 +1229,7 @@ void perf_evsel__exit(struct perf_evsel *evsel) { assert(list_empty(&evsel->node)); assert(evsel->evlist == NULL); + perf_evsel__free_counts(evsel); perf_evsel__free_fd(evsel); perf_evsel__free_id(evsel); perf_evsel__free_config_terms(evsel); -- 2.19.1