Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1341737pxv; Fri, 16 Jul 2021 07:14:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/M+vdjnPtvRBtc6f0iMQfV1hqbxhf+t2CdBKrXL1dslFBGIhvwJFOc+HypDBD1cixUDfA X-Received: by 2002:a7b:c316:: with SMTP id k22mr16617805wmj.56.1626444892859; Fri, 16 Jul 2021 07:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626444892; cv=none; d=google.com; s=arc-20160816; b=Vf4aU5cSAOG8YLqwV5bV1BV1vNc35QtweqzsXMrQnmyNhXqxLRu1XeAkFzlHeuxXiO l2m/G0hJpHB1TsQErUN1jc5kQxjosUWzOrt+A0o2lldnzGDB7zgONBEOYYN/CAAp4kAn QMGSBWG9QnbR6T8J7Q8RfpUiw1p2mSjCJT/CSUqfYLogqUHXGe9wM8irfo3CE1yHaO3z Jk5fZua1HNPjdHD3j5SzDVuU9Imwe6MeUn30RVoghLJcczI3jrYwTrIZiQWL67KkRu4D FN65uudNtoX6ggSSN/VY3x9U8+aSriLg2JEMPpLeYrYXASQFZAVm30oKXU/zvMcRigW3 JDtw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=pHO/OuJ19tFgQlImaLECSeFWZFEdjnugOKUNYJ6qjas=; b=G+97jGRtHmN+1toR0TocWp3LmwKTe2pgu4A/71BiFLxSaC54Ym8jcpYxPRTuHo1w2I 0Kerl5BfLQkhRrgs7gt8MXmbK0IgxaSoCsymmIt0HAUDem+4pTL8YxmJCLeopEtyAobQ Mg5gTihig2GCzaBhBuh/Fft/pQpL6pgB/87bsI0XsuhI7W0QKpTTgeZ0ImNlTGYRYwaX D6KRb3xk/IkfIEgnfhuLpaw9eGdRHoECf4a+kwM2+aLciHCEABVoTJl+iK5krwGO51ab oj3XFWk/PIcqgJBg2ote16gcL2iiV/iw3VgJ3T+oFmMhEltBkyvmQFZeTmzHfqB33ANy vvyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ihnytgiy; 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 c9si11224082ejj.120.2021.07.16.07.14.28; Fri, 16 Jul 2021 07:14:52 -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=Ihnytgiy; 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 S240303AbhGPOPC (ORCPT + 99 others); Fri, 16 Jul 2021 10:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233212AbhGPOPB (ORCPT ); Fri, 16 Jul 2021 10:15:01 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83514C06175F; Fri, 16 Jul 2021 07:12:05 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id j34so5918240wms.5; Fri, 16 Jul 2021 07:12:05 -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:mime-version :content-transfer-encoding; bh=pHO/OuJ19tFgQlImaLECSeFWZFEdjnugOKUNYJ6qjas=; b=Ihnytgiyf1ZDDOEAswttF30OscuVa4F4xg4QtRKFYmu9KjBtibGRiliedYD2zwtgg2 ILgYAA0PZOJVJLTHiMD/9M8qNeleqkhvQb68cn27Jatu1tCwxnH7MY1NT4YJMOOcnDuO SuE1vpkAeriB4jHEtHoKo1rnoRUW0maTHdusSU7Q/+7HESyVnPOq5cP/PmD/UkJ/IpkK gmrjlx6262qEfGa7v70XRtGEvNlvCg7YFi4QE/njHs06qnKs6yL0AKRyZSfdpxLrSJmB Yo52bNZDBHASGeFgKOL9BRpyj1MSIxOnGyJT53IJLCSSI4vw5n4u023h7Unfd1I5vFje 9iMQ== 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:mime-version :content-transfer-encoding; bh=pHO/OuJ19tFgQlImaLECSeFWZFEdjnugOKUNYJ6qjas=; b=VjsexSdF20T6U8Sc7F9kjypKi4UdgE6lrGyO8l0IenoOHdAOA47ChiJHIvdwP1f/13 10oQE2PfVEF0mesQsOUpCy5VvYW/NbarseTBge4LdmAtCl4A35YnijY4cTyaV9MQc6aQ WyUqm0SOseLA80V2YWLmE/bGXy/HA94D8ibYxcEGDhFRoiG8dDCPNMnH+CghRowmNsUj 4tYFf6Rq2LSo+IXDcVDsrlO7LTjzE5+03byNxv4p4mE0kwhCPNsn96LbNK7BQVsxZW61 R9RWOWa5uchLfPHRlaDchmo+J5n1Vwtsovosa0WbaVDDUM5DaLI4hQLaLBbQYhqhK3bS fGuw== X-Gm-Message-State: AOAM533vyfz/61D6Iq8+rovNC7X7NFn7INQt4m4jyHqyTw1YBiXLbZ1T 1JPRu3ks3u8IPTnnxOTBCIE= X-Received: by 2002:a7b:c4d9:: with SMTP id g25mr16350004wmk.108.1626444723940; Fri, 16 Jul 2021 07:12:03 -0700 (PDT) Received: from localhost.localdomain ([2001:b07:6456:fd99:ced0:db1c:53e1:191e]) by smtp.googlemail.com with ESMTPSA id v21sm11327787wml.5.2021.07.16.07.12.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 07:12:03 -0700 (PDT) From: Riccardo Mancini To: Arnaldo Carvalho de Melo Cc: Namhyung Kim , Ian Rogers , Riccardo Mancini , Jiri Olsa , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Zhen Lei , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND] perf data: close all files in close_dir Date: Fri, 16 Jul 2021 16:11:20 +0200 Message-Id: <20210716141122.858082-1-rickyman7@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using perf report in directory mode, the first file is not closed on exit, causing a memory leak. The problem is caused by the iterating variable never reaching 0. Cc: Jiri Olsa Fixes: 145520631130bd64 ("perf data: Add perf_data__(create_dir|close_dir) functions") Signed-off-by: Riccardo Mancini Acked-by: Namhyung Kim --- Hi Arnaldo, I think this patch might have gone lost in the mailbox, submerged by other mails. I'll take advantage of the resend to add the missing 'Fixes:' tag. I didn't flag this as v2 since it contains no logical change, let me know if doing so would've been better. Changes from first send: - collected ack from Namhyung - added Fixes: tag Original: https://lkml.kernel.org/lkml/20210621214220.167927-1-rickyman7@gmail.com/ Thanks, Riccardo --- tools/perf/util/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 8fca4779ae6a8e90..70b91ce35178c5f9 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -20,7 +20,7 @@ static void close_dir(struct perf_data_file *files, int nr) { - while (--nr >= 1) { + while (--nr >= 0) { close(files[nr].fd); zfree(&files[nr].path); } -- 2.23.0