mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf llvm: Fix memory leak of args->fileloc in symbol__disassemble_llvm()
@ 2026-09-17 12:58 Tengda Wu
  2026-09-21 18:36 ` Ian Rogers
  0 siblings, 1 reply; 4+ messages in thread
From: Tengda Wu @ 2026-09-17 12:58 UTC (permalink / raw)
  To: Namhyung Kim, james.clark, xueshuai, Ian Rogers, Adrian Hunter
  Cc: Peter Zijlstra, leo.yan, Li Huafei, Kim Phillips, Mark Rutland,
	Arnaldo Carvalho de Melo, Ingo Molnar, Bill Wendling,
	Nick Desaulniers, Alexander Shishkin, Zecheng Li,
	linux-perf-users, linux-kernel, llvm, Tengda Wu

In symbol__disassemble_llvm(), after calling llvm_addr2line(), if the
subsequent disasm_line__new() fails, the code directly jumps to 'err'
without freeing args->fileloc, leading to a memory leak.

Fix this by explicitly calling free(args->fileloc) before jumping to
the error handling path when disasm_line__new() fails.

Fixes: 048856817888 ("perf annotate: LLVM-based disassembler")
Signed-off-by: Tengda Wu <wutengda@huaweicloud.com>
---
 tools/perf/util/llvm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/llvm.c b/tools/perf/util/llvm.c
index a0deb742a733..dc66f6cc1db6 100644
--- a/tools/perf/util/llvm.c
+++ b/tools/perf/util/llvm.c
@@ -254,8 +254,10 @@ int symbol__disassemble_llvm(const char *filename, struct symbol *sym,
 			       (unsigned int *)&args->line_nr, false, NULL);
 
 		dl = disasm_line__new(args);
-		if (dl == NULL)
+		if (dl == NULL) {
+			free(args->fileloc);
 			goto err;
+		}
 
 		annotation_line__add(&dl->al, &notes->src->source);
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-25  9:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 12:58 [PATCH] perf llvm: Fix memory leak of args->fileloc in symbol__disassemble_llvm() Tengda Wu
2026-09-21 18:36 ` Ian Rogers
2026-09-25  9:56   ` Arnaldo Carvalho de Melo
2026-09-25  9:59     ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®