Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp544329pxv; Thu, 15 Jul 2021 09:55:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKnSTebE/ehz5jOpmUUu1Oy4ld42dTOl/RpatTSRSShfPNcc9qodkMJQFC8vzllcN1/p5H X-Received: by 2002:a6b:2bd6:: with SMTP id r205mr3988449ior.122.1626368107616; Thu, 15 Jul 2021 09:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626368107; cv=none; d=google.com; s=arc-20160816; b=BVen4iqree4iPg8KrJVvZXt7dTXotvEC6FpZ8teKaNJBttIW56UBHYig87wCdTinXU lrQSA03zyY3RZbeMbBdkKwKk/+Y4MP3/PeN/z8DnZkhOMWT6tOkdCKfAdmVcplv3a138 JdNV+Hu/o/kCtSr9JpwRGZpYFr5xrf0Eq5uGAHv+NeqF+YhPySTEOOP5IkXLSRww1RX7 RaDOjaFi7Qn0xMJzexefpJ4qpRos7pn21g6WiMKBpB3Icpkyx8vLw+JibM6H7a7XziLu 99OA8tBKu3Tu3a5an1CBJJW2949IbtPFYwEIR9NF6FxG2RWIBhS+NNixfeVAzQ/U5wTi LKXg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7jnAP5IbnC2zCgq+4HdFt5yTacLKkXCnHyA/6fpXXTI=; b=Zry5sEuRSxeH3rtMT7pQuL6kw0hTe61u1CFgQqXRg76jFSRmp30JdWkfsq/RjCCfc8 X/VaMFEsTFksg0LwcWSey94DKyebUiIGSvM4UgwsX7fD0kVXaB6D0/p/+a6RPMMhEynB C7VvAfOX2ruVlJk5DZ55WgCBKSTVpgE1hHw2hbZAfifvfBcShONVQpqGQG1eKUZmyvrH weTJY7W8Bcgr6xzEf6TXOZ6bcwhfB8FuO4pIV/BaUIt7JIptb7BPV1YG3VvPYrm6AEYn uZMkTDpL5nU/aU6ARo385L5136hbfxX/HsTunOLV7f5ZnOQVPxOaZQbfF19a+9apwILT fVyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q52V+1zO; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 12si7222481ilz.15.2021.07.15.09.54.55; Thu, 15 Jul 2021 09:55:07 -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=@gmail.com header.s=20161025 header.b=Q52V+1zO; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236081AbhGOQK7 (ORCPT + 99 others); Thu, 15 Jul 2021 12:10:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234115AbhGOQKm (ORCPT ); Thu, 15 Jul 2021 12:10:42 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FAF6C061766; Thu, 15 Jul 2021 09:07:47 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id f17so8496066wrt.6; Thu, 15 Jul 2021 09:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7jnAP5IbnC2zCgq+4HdFt5yTacLKkXCnHyA/6fpXXTI=; b=Q52V+1zOzDLhRN44K5XN2+/wa35l5jVQzTrduwWrIrnEHxnj68uzfOAl69kVAvb1ff 6Gge3PklpPXk9GvTATufcb5ee/18MQRstZJlARAeLDmgygHQAjacHxMJWeTt3sfxdpSO LLQJknzO1lZDz+XJUolgnQ84PO/dalKNUUuA2HmpYtr9hEJUm7y/B6IIKpDtuqIZFNO3 dHcGKQHvfFnt4xTtRKJawApgwE78wfNLWembIp1xMCVh/bAVYXX28WBNerR+sjO1Kn7z JThO0r+zfoP+Gf8oXHmdT/6ZDtqiQ2wM58j8T7fB0IoshkOhDeBNz9fsYI1+Gntn81JV gojw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7jnAP5IbnC2zCgq+4HdFt5yTacLKkXCnHyA/6fpXXTI=; b=lgLS6XA/UVhed8xEdiYhIg7qEE1KdUpYDYt3aZ5VJRtBG5UppErzrytVEv03lIjERU j/mW+5bg0yFOIEf3a31ao/1l8GkhAoOKN/Yl4qfn1A2WwGIhWQaYweKgRmPR4gJfyt+A CpkuKu6Z9Rnsn0WHksVTZbjJwsjfqjx2WRorlGL9T7IbvM5uagwFAQc6aql7VMY+dzjf HIFf+3PK5Oq6JE7ivjy5247jq5px2+xU9uca5Hmtuc6/8TuC0gbjkzinF3x4XO6mNFRq KjFrKbzINIoFDyrZz2+AdB8Zn13wlr9KALi7LvMXg7tjulW/2lZUbojV+7+okmW2KnlH Ii1Q== X-Gm-Message-State: AOAM5321oe3eUXs0ql31pAim6tk+OKbgiw5iVK4xbFCoFivI7/1KCqdF PwaG+fSVko65aV5bpts3iNs= X-Received: by 2002:a5d:6dd1:: with SMTP id d17mr6643630wrz.344.1626365266010; Thu, 15 Jul 2021 09:07:46 -0700 (PDT) Received: from honeypot.lan ([2001:b07:6456:fd99:ced0:db1c:53e1:191e]) by smtp.googlemail.com with ESMTPSA id k13sm7446952wrp.34.2021.07.15.09.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 09:07:45 -0700 (PDT) From: Riccardo Mancini To: Arnaldo Carvalho de Melo Cc: Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Riccardo Mancini Subject: [PATCH 16/20] perf trace: free syscall->arg_fmt Date: Thu, 15 Jul 2021 18:07:21 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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