perf trace: Fix leaks of 'struct thread' in set_filter_loop_pids()
authorNamhyung Kim <namhyung@kernel.org>
Thu, 3 Apr 2025 05:42:13 +0000 (22:42 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 8 May 2025 20:11:50 +0000 (17:11 -0300)
I've found some leaks from 'perf trace -a'.

It seems there are more leaks but this is what I can find for now.

Fixes: 082ab9a18e532864 ("perf trace: Filter out 'sshd' in the tracer ancestry in syswide tracing")
Reviewed-by: Howard Chu <howardchu95@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250403054213.7021-1-namhyung@kernel.org
[ split from a larget patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c

index e7d5327123bad6d60fa5ee8a65cc9ccdcc3e0f6d..edab0ff60b3c7f10333bf96770eda5278b461572 100644 (file)
@@ -4128,10 +4128,13 @@ static int trace__set_filter_loop_pids(struct trace *trace)
                if (!strcmp(thread__comm_str(parent), "sshd") ||
                    strstarts(thread__comm_str(parent), "gnome-terminal")) {
                        pids[nr++] = thread__tid(parent);
+                       thread__put(parent);
                        break;
                }
+               thread__put(thread);
                thread = parent;
        }
+       thread__put(thread);
 
        err = evlist__append_tp_filter_pids(trace->evlist, nr, pids);
        if (!err && trace->filter_pids.map)