Re: [PATCH v2 1/2] tools/bpf/bpftool: Reset vmlinux BTF after map commands
From: Jiayuan Chen
Date: Mon Jun 22 2026 - 08:22:11 EST
On 6/22/26 11:12 AM, Yichong Chen wrote:
get_map_kv_btf() caches the vmlinux BTF object when a map uses
btf_vmlinux_value_type_id. map dump released that object when the
command completed, but left the global pointer stale.
The same cached object can also be returned to print_key_value(), which
freed it directly. That leaves btf_vmlinux dangling before the command
cleanup path runs.
Use free_map_kv_btf() for per-entry cleanup, and reset the cached
btf_vmlinux pointer when the map command releases the object. This keeps
batch mode from reusing a freed BTF object.
Signed-off-by: Yichong Chen <chenyichong@xxxxxxxxxxxxx>
You added a Fixes tag to another patch. Should we add one here as well?