Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp692022pxv; Thu, 15 Jul 2021 13:36:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzibHKvfHF03P47ARs/okSRFeg6hpeKqVrMz/LjqLYnLj6GGk42OsM0xc+W6RJQK8/ykDxQ X-Received: by 2002:a17:906:d045:: with SMTP id bo5mr7598755ejb.461.1626381391849; Thu, 15 Jul 2021 13:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626381391; cv=none; d=google.com; s=arc-20160816; b=zgzWIwZVdQmaNGwKnnHkPEMNJM6Pb8Lot4/IhUBpso5h6Zx1DHY/eBJO4HJehcARvO i+TVeJ4rSxGOCkaQ3Wj0v2VaE9MVHxEjef8pWfypyzjRu0rehjdUAwkRQIpkDqHmB2Ag BWv/PeE7tI7u5Atm9BAZ/ud6gjEm51kkIeEWCHB+nQzSGhfyift1NTIn83OFVVY8/tdO upXBPsP9kmRsnOZ0wBFecWDVnF6cS1xTH+tfdt6Dusv/HLD8MyBMbQQtNKVDWNuC5Grb 0eOGfX2TwNtnF8PBPWhJ4K28j68yMVlgfxcqCaGxLSRIWmxHPq8x6XVAEYHid0B5A5Aj oABQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qySeeDiU6dj8MsHyPTP+JFYdfbxPY+xEhZMi8zlMTY0=; b=qEDJQfD5JgahbhZl76wxVtDn/SvEGqCa1IFyLe29aus8iYYoneWf21Xs8avAG+4pSI cUHwyzg+ltYDemNW5DOhM43qwW9r3UUKUexLZclVyDPu9MSTzKSJVZimyH1KPaR1Dul7 4aA03MKIoxXroUNYullj06w+XpwXlPUHY6n80lQOzk1Z+swt+8iWRIGMx6a6Ztp6cjnK ybUqGMm7zuoidy0nVguGPEdv9LSQ1LQjxWLt8wiFzx6d0bca4wqWxh7bnoqfid8UXJzo x8/X7v1z9ANQ688h0xL8pSjYZns9ZTEh84GmUo/w9DswtBSWcuj3AXNh/vtN3QisBu8Z 0mHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="avyb2/Cq"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lh21si8574711ejb.632.2021.07.15.13.36.09; Thu, 15 Jul 2021 13:36:31 -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=@kernel.org header.s=k20201202 header.b="avyb2/Cq"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232171AbhGOUiD (ORCPT + 99 others); Thu, 15 Jul 2021 16:38:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:59386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231250AbhGOUiD (ORCPT ); Thu, 15 Jul 2021 16:38:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 36740613D2; Thu, 15 Jul 2021 20:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626381309; bh=YpW1keL3OrSQeRx/gtZAk34UZN7GkG+ye28MoYCRNC4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=avyb2/CqPbZvgoqyc6w4jmkHwaZdwE9bxW2XD1y70T0ueKMOkyky0kCH9NDcCgn/W vX+GgAbSJiR5bKOnqohDOwWQ2eI4KmDgi4EuMdXgO00XeEpCQArpokOWdpbgdfD8wk 9QK9fDKFv0UnvxrXlD3vZdhZJib+oc9MpASooMmOEHjSeibB/XyC4uAdyCdMYiLgUu RHILyumz25QjTzj7v0bo/VD/UT6uCyKF9eVb9ccmWB0oZfsIgLqysgIfb0IskOmTCb yZgJanWKjjfhZQBiQ/zX4FwuRYx0QGJ+Yggtb5yGb9KX4SB6yK7VKRHIhaMIwM1Fxa aNc1V0rTifNHg== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 894F6403F2; Thu, 15 Jul 2021 17:35:06 -0300 (-03) Date: Thu, 15 Jul 2021 17:35:06 -0300 From: Arnaldo Carvalho de Melo To: Riccardo Mancini Cc: Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH 16/20] perf trace: free syscall->arg_fmt Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Jul 15, 2021 at 06:07:21PM +0200, Riccardo Mancini escreveu: > ASan reports several memory leaks running the perf test > "88: Check open filename arg using perf trace + vfs_getname". > The second of these leaks is caused by the arg_fmt field of syscall not > being deallocated. > > This patch adds a new function syscall__exit which is called on all > syscalls.table entries in trace__exit, which will free the arg_fmt > field. Thanks, applied. - Arnaldo > Signed-off-by: Riccardo Mancini > --- > tools/perf/builtin-trace.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c > index fe26d87ca8ccc14d..d67f02d237eb0c7e 100644 > --- a/tools/perf/builtin-trace.c > +++ b/tools/perf/builtin-trace.c > @@ -2266,6 +2266,14 @@ static void *syscall__augmented_args(struct syscall *sc, struct perf_sample *sam > return augmented_args; > } > > +static void syscall__exit(struct syscall *sc) > +{ > + if (!sc) > + return; > + > + free(sc->arg_fmt); > +} > + > static int trace__sys_enter(struct trace *trace, struct evsel *evsel, > union perf_event *event __maybe_unused, > struct perf_sample *sample) > @@ -4703,9 +4711,15 @@ static int trace__config(const char *var, const char *value, void *arg) > > static void trace__exit(struct trace *trace) > { > + int i; > + > strlist__delete(trace->ev_qualifier); > free(trace->ev_qualifier_ids.entries); > - free(trace->syscalls.table); > + if (trace->syscalls.table) { > + for (i = 0; i <= trace->sctbl->syscalls.max_id; i++) > + syscall__exit(&trace->syscalls.table[i]); > + free(trace->syscalls.table); > + } > syscalltbl__delete(trace->sctbl); > zfree(&trace->perfconfig_events); > } > -- > 2.31.1 > -- - Arnaldo