Commit 7aa42296 authored by Namhyung Kim's avatar Namhyung Kim Committed by Wentao Guan
Browse files

perf mem: Free the allocated sort string, fixing a leak

stable inclusion
from stable-v6.6.54
commit 1490a5dbd55f4b5bfccf6bbbcc7956c8f17e20ba
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAZ3K2

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1490a5dbd55f4b5bfccf6bbbcc7956c8f17e20ba



--------------------------------

[ Upstream commit 3da209bb1177462b6fe8e3021a5527a5a49a9336 ]

The get_sort_order() returns either a new string (from strdup) or NULL
but it never gets freed.

Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Fixes: 2e7f5450 ("perf mem: Factor out a function to generate sort order")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.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>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240731235505.710436-3-namhyung@kernel.org


[ Added Fixes tag ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
(cherry picked from commit 1490a5dbd55f4b5bfccf6bbbcc7956c8f17e20ba)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent 4e122886
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -372,6 +372,7 @@ static int report_events(int argc, const char **argv, struct perf_mem *mem)
		rep_argv[i] = argv[j];

	ret = cmd_report(i, rep_argv);
	free(new_sort_order);
	free(rep_argv);
	return ret;
}