mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 01:08:13 -04:00
perf bpf: Fix map data leak in bpf_metadata_create() on alloc failure
bpf_metadata_create() calls bpf_metadata_read_map_data() which
allocates map.btf and map.rodata. If the subsequent
bpf_metadata_alloc() fails, the code does 'continue' which skips
bpf_metadata_free_map_data(), permanently leaking both allocations.
Fix by calling bpf_metadata_free_map_data() before continue.
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Fixes: ab38e84ba9 ("perf record: collect BPF metadata from existing BPF programs")
Cc: Blake Jones <blakejones@google.com>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -395,8 +395,10 @@ static struct bpf_metadata *bpf_metadata_create(struct bpf_prog_info *info)
|
||||
continue;
|
||||
|
||||
metadata = bpf_metadata_alloc(info->nr_prog_tags, map.num_vars);
|
||||
if (!metadata)
|
||||
if (!metadata) {
|
||||
bpf_metadata_free_map_data(&map);
|
||||
continue;
|
||||
}
|
||||
|
||||
bpf_metadata_fill_event(&map, &metadata->event->bpf_metadata);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user