* [PATCH] perf data: close all files in close_dir
@ 2021-06-21 21:42 Riccardo Mancini
2021-06-22 19:52 ` Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: Riccardo Mancini @ 2021-06-21 21:42 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Namhyung Kim, Ian Rogers, Riccardo Mancini, Peter Zijlstra,
Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Zhen Lei, linux-perf-users, linux-kernel
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 <rickyman7@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf data: close all files in close_dir
2021-06-21 21:42 [PATCH] perf data: close all files in close_dir Riccardo Mancini
@ 2021-06-22 19:52 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2021-06-22 19:52 UTC (permalink / raw)
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
On Mon, Jun 21, 2021 at 2:42 PM Riccardo Mancini <rickyman7@gmail.com> 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 <rickyman7@gmail.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-22 19:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 21:42 [PATCH] perf data: close all files in close_dir Riccardo Mancini
2021-06-22 19:52 ` Namhyung Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.