[PATCH 5.15.y] bpftool: remove duplicate free_btf_vmlinux() definition

From: Suraj Jitindar Singh

Date: Tue Sep 15 2026 - 20:27:54 EST


v5.15.221 backported

a9e2496111aa ("tools/bpf/bpftool: Reset vmlinux BTF after map commands")
[ upstream commit 66d7e39e49b0 ]

which re-adds free_btf_vmlinux(). However, the prerequisite cleanup

52df1a8aabad ("bpftool: remove function free_btf_vmlinux()")

was never backported to 5.15.y, so the tree still carried the original
free_btf_vmlinux() definition. The backport therefore produced two
identical-signature static definitions in tools/bpf/bpftool/map.c and
the build fails:

map.c: error: redefinition of 'free_btf_vmlinux'

Remove the stale pre-existing definition, keeping the one reintroduced
by a9e2496111aa (which also resets btf_vmlinux = NULL). This matches the
current mainline end state.

Fixes: a9e2496111aa ("tools/bpf/bpftool: Reset vmlinux BTF after map commands")
Signed-off-by: Suraj Jitindar Singh <surajjs@xxxxxxxxxx>
---
This is a stable-only fix. Mainline is not affected: 52df1a8aabad
("bpftool: remove function free_btf_vmlinux()") removed the original
definition, and 66d7e39e49b0 later re-added a single one. The duplicate
exists only in the 5.15.y and 6.1.y trees, which received the backport
of 66d7e39e49b0 without the prerequisite 52df1a8aabad. There is
therefore no single upstream commit to cite; the fix restores the
mainline end state.

tools/bpf/bpftool/map.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index cf257da20195..54d855ac5408 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -828,12 +828,6 @@ static void free_map_kv_btf(struct btf *btf)
btf__free(btf);
}

-static void free_btf_vmlinux(void)
-{
- if (!libbpf_get_error(btf_vmlinux))
- btf__free(btf_vmlinux);
-}
-
static int
map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,
bool show_header)
--
2.47.3