Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3710044pxv; Mon, 26 Jul 2021 09:58:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywi8WxGGA1L2nl0AfOpXZwYox6Reda5Fi3+sthaC54jAktyEqB4989rV/4c0fwjEznBkcx X-Received: by 2002:a02:aa8b:: with SMTP id u11mr17161916jai.43.1627318704630; Mon, 26 Jul 2021 09:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627318704; cv=none; d=google.com; s=arc-20160816; b=IHgeMSfr2RB4uo1vYZSVALyJPXMbhc2+ap/eKt+AVm+xEhtgfEOqTxx53epN710Hd7 3M4HL/7IerXCE4KAZmLy11bCPuFyxVqTFWTb35+GiQ1i7wnSCzUeslnnc+dexiNPr1MR M9aA0liI0ioBDCg/bS1X1vpp0vep9XUWAz5xbvWE0LV9iw+i4XTBZxhYFgHLDAgfhqUX tpTn635F3YL/yKd26Vc0IRv4/l4r9WjGVCeRv/K7POfFuZFwHTur79fjfhGhVZLvZ0O3 I+rNKMtTWIHxT5bgamQD66/bTa6PaQAMHx124vio60Ll7QcNkYRP5LCAFOe/CaBmwpFq EJkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kh/1l5DpDJHOLP1hS4v7BIGyZnrFPg0ZhxBTe0pvsiE=; b=IxfY66pZNNkkjnkamlZqhd7AN+wmgSS+KbBMiLNwyE2ayQ6fZhbPtoBYB8uDFB9LXT qYBC+eUymAFc3mmwzrQWbJPPgD+Zpap8+24yaEq4MZoVEu/bTv7Bx0lgy0ZZvAtaFzMS 7ev6i+j0WeHjmCwuLEjY0t+2GJcrusDT5Jb0hxA4l4vUg3APK+eWEm5BewxF9x++v63V vIcWzcN/vzExjA2JrSTSG1xutxnkK59SNKbhOV9JLUjn1Zk9kI7a2vHnazdpvIy4xsIi Crun0/c05wEv5E6uMnsYvwFIFl0fM0CjxfXfsKAK/86xwaOWUXgUkxyWCoZhX0D8iRKK A1/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kNUn4Kmv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u3si410629ilk.94.2021.07.26.09.57.58; Mon, 26 Jul 2021 09:58:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kNUn4Kmv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237521AbhGZP3R (ORCPT + 99 others); Mon, 26 Jul 2021 11:29:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:56636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236449AbhGZPQr (ORCPT ); Mon, 26 Jul 2021 11:16:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C400660F38; Mon, 26 Jul 2021 15:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315036; bh=DYJU4jqX5WEXFYWKhHqfdXoZ8elYo2C9RlYka+qwH24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kNUn4KmvvwoVZyg1VKw1T9t+M26dsDPDq3G3QN8HjZqZttvYkUvtXFN/S6qMWNsF5 FVhum6JCXOwk0aN1MN8tpiHgPZ9m/HSc2IrIPW2oYzMcMCxOZhl+zRhRB1VN5cuVak ly7mSu8gokwvHh14qckcSv7MxWHMV7ApeHUwxCqA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riccardo Mancini , Ian Rogers , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 026/108] perf script: Fix memory threads and cpus leaks on exit Date: Mon, 26 Jul 2021 17:38:27 +0200 Message-Id: <20210726153832.540872281@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Riccardo Mancini [ Upstream commit faf3ac305d61341c74e5cdd9e41daecce7f67bfe ] ASan reports several memory leaks while running: # perf test "82: Use vfs_getname probe to get syscall args filenames" Two of these are caused by some refcounts not being decreased on perf-script exit, namely script.threads and script.cpus. This patch adds the missing __put calls in a new perf_script__exit function, which is called at the end of cmd_script. This patch concludes the fixes of all remaining memory leaks in perf test "82: Use vfs_getname probe to get syscall args filenames". Signed-off-by: Riccardo Mancini Fixes: cfc8874a48599249 ("perf script: Process cpu/threads maps") Cc: Ian Rogers Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/5ee73b19791c6fa9d24c4d57f4ac1a23609400d7.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/builtin-script.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index da016f398aa8..f3ff825d9dd3 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2474,6 +2474,12 @@ static void perf_script__exit_per_event_dump_stats(struct perf_script *script) } } +static void perf_script__exit(struct perf_script *script) +{ + perf_thread_map__put(script->threads); + perf_cpu_map__put(script->cpus); +} + static int __cmd_script(struct perf_script *script) { int ret; @@ -3893,6 +3899,7 @@ out_delete: perf_evlist__free_stats(session->evlist); perf_session__delete(session); + perf_script__exit(&script); if (script_started) cleanup_scripting(); -- 2.30.2