[PATCH 0/2] tools/bpf/bpftool: Fix vmlinux BTF state cleanup

From: Yichong Chen

Date: Sun Jun 21 2026 - 22:34:25 EST


This series follows up on the bpftool cgroup vmlinux BTF leak fix.

map.c and struct_ops.c also free the global vmlinux BTF object
without resetting the global pointer. In batch mode, later commands can
see stale non-NULL state and reuse freed memory instead of loading
vmlinux BTF again.

Patch 1 resets the map dump vmlinux BTF pointer after freeing it.
Patch 2 resets the struct_ops vmlinux BTF pointer and the cached
bpf_map_info state derived from it.

Build tested with:

make -C tools/bpf/bpftool

Yichong Chen (2):
tools/bpf/bpftool: Reset vmlinux BTF after map dump
tools/bpf/bpftool: Reset vmlinux BTF after struct_ops commands

tools/bpf/bpftool/map.c | 8 +++++++-
tools/bpf/bpftool/struct_ops.c | 11 ++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)

--
2.51.0