Message ID | 20221229090903.1402395-1-linmq006@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2310926wrt; Thu, 29 Dec 2022 01:22:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXuVbSmzf4SaUIRIk2WxcAkAPseZCuNnk1Sqqzta2ewx7YUd+y4v+UJHTQCOEcMhvWwG+R1p X-Received: by 2002:a17:907:d68e:b0:7bd:43e9:d3ab with SMTP id wf14-20020a170907d68e00b007bd43e9d3abmr23521735ejc.52.1672305732893; Thu, 29 Dec 2022 01:22:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672305732; cv=none; d=google.com; s=arc-20160816; b=YTPxxW2RBeOQxovCK6rAzADMcUoCd+yi62Yl/VZcGWcXwGbWrnUNIQyif9c9Hwo7hB kWdnANGqTIh1vFJadZvnBHoGD1HR8ptYOn86H3hUHSS5BNJ83Qx/UhqJ3iZkMWv6JMc1 IDnT+YuqlWEuRgb7BBcDYibSC+eEo9t/YNUPVT+Mw8t+ohdQK3i7gZmzv/v6G9/1Odjh 6TDRD9WQNhvj6W529XMxnAD25Nyh8ksqB6CysVlYNIcrGxKCnWWWyvIDOzuTMIliyad3 WI37XIJvGnvIhfR4ReKEKzGEaAHT2ky6S3wdKWzqnNbFxGR9eFCw7Ujj2GdMymwjyQQS 0tMQ== 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:to:from:dkim-signature; bh=sUCELAjzLAgQLyNWUnFXqm5TavnSZ9QT/V/+24DubtQ=; b=bDD5kakpfQhhvlUssyPpKI3N4duR4UN98X9p/IA5GirOrIuEVnvJsBXAh4AJu/2SxJ /8hT0xmY4kohZ2wtkUJc0dumzhujYYDzCbqWsIXUYD1speWDpolG8MAZ9+ev9c+zn4E6 f5qnb3Cn9+SfAzQBnNUVKzP521CKLaZfhkAc0yG8w3YfDCBl3tymKVT24fhaNVuBTn45 kXLRkfZUL0mxreo82YXt7IYvOsmTEYsU1E1p0EdhQPBWxRzS/BmalJmw12BHUujLFUDf Kz11mtBKr0HwLean0n/jg8jldEATu74pg/RjlCgcpQVwScAWd2tmuMPGOn2fk1aXnK6A EF1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="V/izTH55"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ww6-20020a170907084600b007c1946d08b3si11214727ejb.989.2022.12.29.01.21.48; Thu, 29 Dec 2022 01:22:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="V/izTH55"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232179AbiL2JJ3 (ORCPT <rfc822;eddaouddi.ayoub@gmail.com> + 99 others); Thu, 29 Dec 2022 04:09:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbiL2JJZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Dec 2022 04:09:25 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78C2D12D08; Thu, 29 Dec 2022 01:09:24 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id u4-20020a17090a518400b00223f7eba2c4so18385204pjh.5; Thu, 29 Dec 2022 01:09:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=sUCELAjzLAgQLyNWUnFXqm5TavnSZ9QT/V/+24DubtQ=; b=V/izTH55F5bQ7NezmIPSUuxY/ypaWDJei156ZGjl2299G/7wnf9W3SvP6DCy5t180c leAK2igc6IHpKxIrOm68akg8b/6GFpRzxTrxEX8cb91j1ED44fhb7S5qtduCRZMWF0q+ 2k80gdTCDpnU7Dq3TZ5K198jYQKfquCBDWm+DbtZQ8pgnZwk5HMHk5HOHFFnp5KANIgO HfUKwuMzfPWpeaGBH7AHm6Sf90DQ67WiYmJ65DIYNxNU3RHdi/3Ish90yi1iljXj3kUs JhUFeNKhOJ6nFK1la4KdE+ZLTcNFazjmnbFFonWZpMvI0Y6ZcDS4fO6nc+q6ttKlzNGc 3sfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sUCELAjzLAgQLyNWUnFXqm5TavnSZ9QT/V/+24DubtQ=; b=6G7Up7hqyTGa4GPKb9BCC9D68YqAcV9Y5fgDl5emzCn6gaA6/oEo4fogr5+fyht2TO u2L0Y1OmTHo4xFOpOuxLjONgMvWU4tI5rzThlkvs2yv/RFsMY+Olv5yZck//g4Zd+CE1 XbAP9EiJSXM/PvEiulQQd2OTd2EW9fLjzj/+Dc9WUefPI5wIlFjEq4j4zeBb+vxkJCqe SRVlVKotrkjXBkngn3jNc8M78P7R+mIO2kFJ0lASmxC4e1irUBqWmEnngOvPg+tSyXrH Ah31ZdlHuOJS+t1Ax80u4TKxomzZ1b6caj9SnFgEQxgP02XWwwKm/QP3drMJAkEDhEeT sR5A== X-Gm-Message-State: AFqh2krSVWxJP4weU15arNywXhvkqa3CsHV/b6zra7koNW7BCgNgfscg WIz+UjUvEvQp9g5Dmf9MODc= X-Received: by 2002:a05:6a20:3d03:b0:ad:2abb:5a5e with SMTP id y3-20020a056a203d0300b000ad2abb5a5emr62802216pzi.61.1672304963990; Thu, 29 Dec 2022 01:09:23 -0800 (PST) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id y4-20020a655b44000000b0047899d0d62csm10624971pgr.52.2022.12.29.01.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 01:09:22 -0800 (PST) From: Miaoqian Lin <linmq006@gmail.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Adrian Hunter <adrian.hunter@intel.com>, Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>, Miaoqian Lin <linmq006@gmail.com>, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] perf tools: Fix resources leak in perf_data__open_dir Date: Thu, 29 Dec 2022 13:09:00 +0400 Message-Id: <20221229090903.1402395-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753539656350500386?= X-GMAIL-MSGID: =?utf-8?q?1753539656350500386?= |
Series |
perf tools: Fix resources leak in perf_data__open_dir
|
|
Commit Message
Miaoqian Lin
Dec. 29, 2022, 9:09 a.m. UTC
In perf_data__open_dir(), opendir() opens the directory stream.
Add missing closedir() to release it after use.
Fixes: eb6176709b23 ("perf data: Add perf_data__open_dir_data function")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
tools/perf/util/data.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On 29/12/22 11:09, Miaoqian Lin wrote: > In perf_data__open_dir(), opendir() opens the directory stream. > Add missing closedir() to release it after use. > > Fixes: eb6176709b23 ("perf data: Add perf_data__open_dir_data function") > Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> > --- > tools/perf/util/data.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c > index a7f68c309545..fc16299c915f 100644 > --- a/tools/perf/util/data.c > +++ b/tools/perf/util/data.c > @@ -132,6 +132,7 @@ int perf_data__open_dir(struct perf_data *data) > file->size = st.st_size; > } > > + closedir(dir); > if (!files) > return -EINVAL; > > @@ -140,6 +141,7 @@ int perf_data__open_dir(struct perf_data *data) > return 0; > > out_err: > + closedir(dir); > close_dir(files, nr); > return ret; > }
Em Thu, Dec 29, 2022 at 01:27:39PM +0200, Adrian Hunter escreveu: > On 29/12/22 11:09, Miaoqian Lin wrote: > > In perf_data__open_dir(), opendir() opens the directory stream. > > Add missing closedir() to release it after use. > > > > Fixes: eb6176709b23 ("perf data: Add perf_data__open_dir_data function") > > Signed-off-by: Miaoqian Lin <linmq006@gmail.com> > > Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> Thanks, applied. - Arnaldo > > --- > > tools/perf/util/data.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c > > index a7f68c309545..fc16299c915f 100644 > > --- a/tools/perf/util/data.c > > +++ b/tools/perf/util/data.c > > @@ -132,6 +132,7 @@ int perf_data__open_dir(struct perf_data *data) > > file->size = st.st_size; > > } > > > > + closedir(dir); > > if (!files) > > return -EINVAL; > > > > @@ -140,6 +141,7 @@ int perf_data__open_dir(struct perf_data *data) > > return 0; > > > > out_err: > > + closedir(dir); > > close_dir(files, nr); > > return ret; > > }
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index a7f68c309545..fc16299c915f 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -132,6 +132,7 @@ int perf_data__open_dir(struct perf_data *data) file->size = st.st_size; } + closedir(dir); if (!files) return -EINVAL; @@ -140,6 +141,7 @@ int perf_data__open_dir(struct perf_data *data) return 0; out_err: + closedir(dir); close_dir(files, nr); return ret; }