linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Miaoqian Lin <linmq006@gmail.com>,
	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>,
	Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf tools: Fix resources leak in perf_data__open_dir
Date: Thu, 29 Dec 2022 13:27:39 +0200	[thread overview]
Message-ID: <d0cf59ae-87c3-3aab-34fa-aa88ea467423@intel.com> (raw)
In-Reply-To: <20221229090903.1402395-1-linmq006@gmail.com>

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;
>  }


  reply	other threads:[~2022-12-29 11:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-29  9:09 [PATCH] perf tools: Fix resources leak in perf_data__open_dir Miaoqian Lin
2022-12-29 11:27 ` Adrian Hunter [this message]
2023-01-02 14:46   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d0cf59ae-87c3-3aab-34fa-aa88ea467423@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexey.v.bayduraev@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linmq006@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).