Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3713536pxv; Mon, 26 Jul 2021 10:02:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwssVu1qXfjlnnsKMwq4p5Bfyf2SqeTNyhS80zYvwZTWh15YViO2gDWNAGFuac2AytL4Jhg X-Received: by 2002:a17:907:3e22:: with SMTP id hp34mr18107974ejc.334.1627318977747; Mon, 26 Jul 2021 10:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627318977; cv=none; d=google.com; s=arc-20160816; b=PJgeSdmqhyiKpxIFUg3BKWdMlq0jdSCHTCawylgX/+6MvCbo8dY5QFAz3wNNr85QVA +wuc8xUB/v5KNBgycXv+Tj1m4sIgvFqRPeXQgFvLAnzVN26i79d7xC1jQq4SP8HeOYKt Ox05dR+1EBPdkAoyE2YTBT/+lT5UIQ+ParuaJ+USNzpeSo9/Fcw5fELvflFqmtoQs+99 uZnJBP/p9tsdhl/nZW3ulgL2Tx+4VV73sqFkQB1xT6ghzI5h1cKxmIS8Vxn9isDNWrQ2 ZVCQSmFYftxnB5QCM/+vzn82TgfZQ1zYSpAKjkPOjGyaTJzDCEaoPOuOM5wHUmmM4ScZ ciXA== 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=E7if68YD8/qgfQroiLT2/DFQdWi597e2eY6qTG8Rzjc=; b=xYfpRq0GDn5dpSyND/kv9VxfND+NfeeeAbp6F9vNNIIdiyzFYQZdjDw4WzYSVV3byD HvVYeDWyVOltKJpWmqSKH98NSGfihfLy2M7Mrdz5ei4x1edvP1+Nsq7Q+YL3DbHpzf75 6s5rgpFO5W2FRN0y/nfxr0tSkC3aFPWAor0nH4/Wy8DjHDyjFVy29kEMOYlHQMUQ8LH+ utEkRHkP33WN3w9HwHKMDFmRXcWRmrXq7aneMALIe3CfCnmGeyYwHpuiVW2T4yhUCEOZ 3PgbF7XYE2o0tWrXVYE90LH0dRd90raMo1+y5XinMVPQmTY4uvufZ0l+s41LruqzvYiy jOlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1qLsk2Im; 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 k26si494535eds.397.2021.07.26.10.02.34; Mon, 26 Jul 2021 10:02:57 -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=1qLsk2Im; 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 S234422AbhGZPgy (ORCPT + 99 others); Mon, 26 Jul 2021 11:36:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:35226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237135AbhGZPVM (ORCPT ); Mon, 26 Jul 2021 11:21:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6C5E60E09; Mon, 26 Jul 2021 16:01:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315300; bh=TvVsHlZq1ZRCpVFuf7yyidr2Jm3eg1B1/yVpqe41r7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1qLsk2Imp22DAQ8hoMvt06OZ28pfS9ERQUyICk0gpwgFxdr/ERZArHjO0rDyDeASn 50vuyTjS1TbT5PjYy3GAfBlBThJbR87ZE4gqRRIQ/zM/H3N2mH2hxv81RmVEnUwKs0 f/UBZ1agLvhCGW7Z72/1j2yeroBYteBkvv0T907U= 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.10 043/167] perf script: Fix memory threads and cpus leaks on exit Date: Mon, 26 Jul 2021 17:37:56 +0200 Message-Id: <20210726153840.841353924@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@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 48588ccf902e..2bb159c10503 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2483,6 +2483,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; @@ -3937,6 +3943,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