Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3676002pxv; Mon, 26 Jul 2021 09:11:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyT5mw/cBf0357WFSIJUYQBu0QloSRVIGoo/Qnzkx3XO0jHfRxo/CAXElluU4LLg+1N3+hC X-Received: by 2002:a02:a115:: with SMTP id f21mr16978336jag.3.1627315890793; Mon, 26 Jul 2021 09:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315890; cv=none; d=google.com; s=arc-20160816; b=P9opnq0Mw7t4PzsFHk1iRASEZHLD6Wur5KceFio5MC1NxFOQPYQGVZt6FdABrHMjXF iq+ZG/OdGmXWg7tQMIbxtXFOguquiO++WWmFMCew7jQyasY40/ZyT71rBZkELb0F7sPJ csYIZTmNWUqjH+JsqiNN4hBPSBofJE7KNYlhETr1TLtErbi2ukXv7lYVYHO3w+M2leSd yrwqAJjnfnBw9QniWT0ZRcXjmbMbxNklgvarebP6ljLtl6h4jHIaJsultg1jeXX19y7T wUC/TtGkBEyOs2qGlLKqlN/7HRwzE0xD4ZGe+YVEBum6Wkre474yUAN+oMbmLJdqwAny UiXQ== 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=Na0kYCtvibzuo6UiPXSAACuj2lEL8oidYthC95hrxiU=; b=guobRq1cu4KlJTq8NdVpqvcJG6pmg/v0C3U4+UFIeQSbGO7EIiHC3Bv3ePF/Pk1jXX jP/ypnDcQQWqHv4YKWg4lIm1i/sGnTximz01kthns3hBub0jHk536AJZjG1jG4/ffZnG /k3gn6GTFqx+4av8PLWvAST9DzMpOnTR2PVPMqFEKG1nFlYSuAN9WK3iY3bfbFvUBWzh SXF4ALQN8Cp3lDh3/BPgxMOnr5SENQKbWcI44yc/mvWcVe6AHGuw2Y6nROmH17+y07pK zVTUDtl/Hbsv/x97Bbp42jwf4RPTqgDCAICrdapjDj9vaktzY7q9Zu+tEMYbea+9sJyQ 4kvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0rpqOGvS; 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 i16si251066jam.109.2021.07.26.09.11.16; Mon, 26 Jul 2021 09:11:30 -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=0rpqOGvS; 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 S237643AbhGZP3T (ORCPT + 99 others); Mon, 26 Jul 2021 11:29:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:56898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236473AbhGZPQ5 (ORCPT ); Mon, 26 Jul 2021 11:16:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C945860F6E; Mon, 26 Jul 2021 15:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315045; bh=uILrd27LuKCR1EmJTAObJYkM+IjVDvGFMgyZD1RLD2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0rpqOGvSePHZpxyLQ1UBXF0avX2HJJBNV0+z4Nf0fNvtL7lGq3KbtCTC2s5tGEGyO XUkOno/pHBbMO1HnWZP8O8UfxSDHnWrLRbCxOk5FHYLWtDM/mHvZb0u4sc1kbHdCTb v7GgVAzInsAyXTeXpI3Hd3DiMXCkiIsLuvR74ZTU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riccardo Mancini , Namhyung Kim , Alexander Shishkin , Ian Rogers , Jiri Olsa , Mark Rutland , Peter Zijlstra , Zhen Lei , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 029/108] perf data: Close all files in close_dir() Date: Mon, 26 Jul 2021 17:38:30 +0200 Message-Id: <20210726153832.631447432@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@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 d4b3eedce151e63932ce4a00f1d0baa340a8b907 ] 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. Fixes: 145520631130bd64 ("perf data: Add perf_data__(create_dir|close_dir) functions") Signed-off-by: Riccardo Mancini Acked-by: Namhyung Kim Cc: Alexander Shishkin Cc: Ian Rogers Cc: Jiri Olsa Cc: Mark Rutland Cc: Peter Zijlstra Cc: Zhen Lei Link: http://lore.kernel.org/lkml/20210716141122.858082-1-rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- 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 7534455ffc6a..a3f912615690 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.30.2