Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5003839pxj; Tue, 22 Jun 2021 12:53:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxs/aNWNrbZ2fqDkAA/vfdayaoaxaRRIljlDkfrHw5xUIHFcN/Y726m2rvsfN4hzCgeGkhR X-Received: by 2002:a92:dcc5:: with SMTP id b5mr250521ilr.306.1624391629345; Tue, 22 Jun 2021 12:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624391629; cv=none; d=google.com; s=arc-20160816; b=eLtc/PZ/G2XS6yzEmVtH6pET7AMkEblEPAPiP+8G1B8hWO42dqGKrNcXuouz/pwMuE /1QmDAPkt1NkeM5oFqSi08NXvDGMFqq92qxX1yd+HJcj+wLtMeelU30WiLhDEB2bJl44 ujRM30jVoqXcJzguRMAkhSxPOAaiEW+3uOBuDMmpF4xScJmfvScSrit1bmdyJJrtNTYF sYyTE7/nOcFBqhfWD/AH9zDN5BierIIVz3lmd7bijUCA9YljFJftA4c6kZB7QVBaQR3o JuMMJ94smZlvpl5deLCl3UcHQQ/H8qNjNuRT5C5IoV3Ri4DI4Z7OM6K2AjKyl3Xsm23O cc9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=RMgSwwLZ69FlltYZhwtvgsM5zGBul1hA2YxAck7xfRc=; b=Hc9RNHt+NPRsMtFIakymqM7D6uLV9Nx4xdmmuQg19gv6+UZmJBEChpxMyJH0F9fHpV smQ9TThot28QZ/hgVXv556Lde5V1/JlzrxmupiIeMK4JegcQKeztqNs/bbd4Jqt9/JNk 4UkWe5mmlkF35EN4fpEIuJMgDbPCCjCLRLRMwWwSe+Q3W3aiu3yyVIOH2lfIJxWH34AZ OYWIQsAt7++jHe5F5LaCZ9+Gj/r1hVDNuIGrwUKzXUz1Hn/DEUMZk1HL2uEzxW1agYDV I1pb3yFdthtjnrNsr9/50qk2aIJMhFO8o/AJDU7uAcfGeeH2mOdG0B3v7DQ43Dswy5pc B15g== ARC-Authentication-Results: i=1; mx.google.com; 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 d187si6541791iog.56.2021.06.22.12.53.36; Tue, 22 Jun 2021 12:53:49 -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; 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 S232582AbhFVTzU (ORCPT + 99 others); Tue, 22 Jun 2021 15:55:20 -0400 Received: from mail-lf1-f47.google.com ([209.85.167.47]:36455 "EHLO mail-lf1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231726AbhFVTzU (ORCPT ); Tue, 22 Jun 2021 15:55:20 -0400 Received: by mail-lf1-f47.google.com with SMTP id d16so29715lfn.3; Tue, 22 Jun 2021 12:53:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RMgSwwLZ69FlltYZhwtvgsM5zGBul1hA2YxAck7xfRc=; b=ThjISDgsl2XT9GzuK2djt4hP9HhC93Pe1qzO+WKVO6SoY3SLdMsyYelrbgVtX/uReR m6/EKHOOn1c30XNr181CJ8qMBer7iVCRhEoPDpCKzAJ8IFzY7iY4WzcAPQLZ8WmZwMuD e14IwASuUz+1t+LaMF/X4P50Dis8g5KTK7v7o761aqKoeVv0pvjs+5X+3v66i8TIskNU zo4PJY2y8YXcxYq8KOxaA5baHJhoxjr72BN555k/ZSQy7/Voi8WaA/X6z119pywsXZYO mzaFYlQEj5fAQxzoHAVqkGerxD5pGYZmHsBcplYM4N7l218pgGDrDZ0/0NoiNI/TRir1 ix+w== X-Gm-Message-State: AOAM5315Kt88I6zb8n6zH7LCdUF3ZcTzzBSNkutjEssgOqWvvV7Jh2G/ qY+SWg2Y7XEb+dsVpzZaNS2IaNwmJSO/XkhDF28= X-Received: by 2002:a2e:9984:: with SMTP id w4mr4471550lji.393.1624391582748; Tue, 22 Jun 2021 12:53:02 -0700 (PDT) MIME-Version: 1.0 References: <20210621214220.167927-1-rickyman7@gmail.com> In-Reply-To: <20210621214220.167927-1-rickyman7@gmail.com> From: Namhyung Kim Date: Tue, 22 Jun 2021 12:52:51 -0700 Message-ID: Subject: Re: [PATCH] perf data: close all files in close_dir To: Riccardo Mancini Cc: Arnaldo Carvalho de Melo , Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Zhen Lei , linux-perf-users , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 21, 2021 at 2:42 PM Riccardo Mancini wrote: > > 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. > > Signed-off-by: Riccardo Mancini Acked-by: Namhyung Kim Thanks, Namhyung > --- > 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 8fca4779ae6a..70b91ce35178 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 >