]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
perf sched: Free thread->priv using priv_destructor
authorNamhyung Kim <namhyung@kernel.org>
Thu, 3 Jul 2025 01:49:36 +0000 (18:49 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 3 Jul 2025 18:28:29 +0000 (11:28 -0700)
In many perf sched subcommand saves priv data structure in the thread
but it forgot to free them.  As it's an opaque type with 'void *', it
needs to register that knows how to free the data.  In this case, just
regular 'free()' is fine.

Fixes: 04cb4fc4d40a5bf1 ("perf thread: Allow tools to register a thread->priv destructor")
Reviewed-by: Ian Rogers <irogers@google.com>
Tested-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250703014942.1369397-3-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/builtin-sched.c

index b7bbfad0ed600eee18a6e51b55c7e6685938384e..fa4052e040201105ed6bda8b76dfcfec12489aee 100644 (file)
@@ -3898,6 +3898,8 @@ int cmd_sched(int argc, const char **argv)
        if (!argc)
                usage_with_options(sched_usage, sched_options);
 
+       thread__set_priv_destructor(free);
+
        /*
         * Aliased to 'perf script' for now:
         */