summaryrefslogtreecommitdiff
path: root/scripts/basic
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2026-08-02 11:27:12 -0300
committerNamhyung Kim <namhyung@kernel.org>2026-08-05 11:20:03 -0700
commitfe3ab00d55aa56b4d55cbc1150448f0aadd6732c (patch)
treea8495a4d6ea51944381121e06dbf493365515188 /scripts/basic
parent38ba525335c4399b15c9be0f81de304e94ccb462 (diff)
downloadlinux-fe3ab00d55aa56b4d55cbc1150448f0aadd6732c.tar.gz
linux-fe3ab00d55aa56b4d55cbc1150448f0aadd6732c.zip
perf libbfd: Fix memory leaks and NULL fclose in BPF disassembly
symbol__disassemble_bpf_libbfd() has four resource management bugs: 1. free(prog_linfo) leaks internal arrays. bpf_prog_linfo contains raw_linfo, raw_jited_linfo, nr_jited_linfo_per_func, and jited_linfo_func_idx pointers that are only freed by the proper destructor bpf_prog_linfo__free(). 2. open_memstream(&buf, &buf_size) allocates a dynamic buffer that the caller must free after fclose(). The function calls fclose(s) but never free(buf), leaking the stream buffer on every call. 3. args->line = strdup(srcline) is immediately consumed by disasm_line__new(args) which internally calls strdup(args->line) again via annotation_line__init(). The first strdup result is then overwritten by args->line = buf + prev_buf_size without being freed. 4. If open_memstream() fails, the error path jumps to 'out:' which calls fclose(s) with s == NULL — undefined behavior. Fix by using bpf_prog_linfo__free(), initializing buf to NULL, adding free(buf) after fclose(s), guarding fclose() against NULL, and removing the redundant strdup since annotation_line__init() makes its own copy. Fixes: 6987561c9e86eace ("perf annotate: Enable annotation of BPF programs") Reported-by: sashiko-bot <sashiko-bot@kernel.org> Cc: Song Liu <songliubraving@fb.com> Reviewed-by: Ian Rogers <irogers@google.com> Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'scripts/basic')
0 files changed, 0 insertions, 0 deletions