Re: [PATCH] perf llvm: Fix memory leak of args->fileloc in symbol__disassemble_llvm()
From: Arnaldo Carvalho de Melo
Date: Fri Sep 25 2026 - 06:04:31 EST
On Fri, Sep 25, 2026 at 11:56:04AM +0200, Arnaldo Carvalho de Melo wrote:
> On Mon, Sep 21, 2026 at 11:36:08AM -0700, Ian Rogers wrote:
> > On Thu, Sep 17, 2026 at 5:58 AM Tengda Wu <wutengda@xxxxxxxxxxxxxxx> wrote:
> > > 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@xxxxxxxxxxxxxxx>
>
> > Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>
>
> I replaced the free() with a zfree(&), minor.
I understand why you didn't use zfree(), to make it consistent with the
other free, will keep it and leave the zfree() for later.
Sorry about the noise,
- Arnaldo