[REGRESSION] 5.15.221 & 6.1.188: bpftool: redefinition of 'free_btf_vmlinux'

From: Suraj Jitindar Singh

Date: Tue Sep 15 2026 - 19:58:50 EST


Hi Greg, all,

Building bpftool from the v6.1.188 and v5.15.221 stable tags fails with a
duplicate function definition:

tools/bpf/bpftool/map.c: error: redefinition of 'free_btf_vmlinux'
note: previous definition of 'free_btf_vmlinux' was here

This is a stable-only regression caused by a bad backport (the fix is
correct in mainline). It affects only the current head of each series:

Tree Broken Last good
5.15.y v5.15.221 v5.15.220
6.1.y v6.1.188 v6.1.187

6.6.y, 6.12.y, 6.18.y and 7.2.y are NOT affected -- those trees already
carried free_btf_vmlinux() in its current (btf_vmlinux = NULL) form
before this cycle, so the backport deduplicated cleanly there.

Root cause
----------
In 6.1.y the backport of

660a19e46942 ("tools/bpf/bpftool: Reset vmlinux BTF after map commands")
[mainline 66d7e39e49b0]

*adds* a free_btf_vmlinux() definition. But 6.1.y still carried the older
definition that mainline had already removed, so the result is two
identical-signature static definitions in map.c and the build breaks.

The same happens in 5.15.221, where two commits applied in the same
release collide:

a9e2496111aa ("tools/bpf/bpftool: Reset vmlinux BTF after map commands")
44f58f0c5202 ("bpftool: Use libbpf_get_error() to check error")

the latter keeping the old guarded form (if (!libbpf_get_error(...)))
while the former adds the new form.

Reproducer (no kernel build / .config needed)
---------------------------------------------
git checkout v6.1.188 # or v5.15.221
gcc -fsyntax-only tools/bpf/bpftool/map.c \
-Itools/bpf/bpftool -Itools/include -Itools/include/uapi \
-Itools/lib -Itools/bpf/bpftool/../../include

=> map.c: error: redefinition of 'free_btf_vmlinux'

Suggested fix
-------------
Drop the stale pre-existing definition and keep the one introduced by the
backport (which also resets btf_vmlinux = NULL, matching mainline
66d7e39e49b0). For 6.1.y:

--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -817,11 +817,6 @@ static void free_map_kv_btf(struct btf *btf)
btf__free(btf);
}

-static void free_btf_vmlinux(void)
-{
- btf__free(btf_vmlinux);
-}
-
static int
map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,

For 5.15.y the same fix applies -- remove the older
libbpf_get_error()-guarded free_btf_vmlinux() definition, keeping the
one that resets btf_vmlinux = NULL.

Happy to send this as a formal patch per-tree if you prefer.

#regzbot introduced: 660a19e46942

Thanks,
Suraj