summaryrefslogtreecommitdiff
path: root/tools/bpf
diff options
context:
space:
mode:
authorYichong Chen <chenyichong@uniontech.com>2026-06-24 10:50:55 +0800
committerAndrii Nakryiko <andrii@kernel.org>2026-07-01 11:17:43 -0700
commitf7f540e19751face50c68bb9ce58460fcb46c293 (patch)
treebfa65907811f4a6c2276a73f1b1eb4be525d7770 /tools/bpf
parent66d7e39e49b0dd57610c9b63afc65b4d5690983b (diff)
downloadlinux-next-f7f540e19751face50c68bb9ce58460fcb46c293.tar.gz
linux-next-f7f540e19751face50c68bb9ce58460fcb46c293.zip
tools/bpf/bpftool: Reset vmlinux BTF after struct_ops commands
struct_ops frees the global btf_vmlinux object. In batch mode, a later struct_ops command can reuse stale state. Reset the BTF pointer and cached map info state. Fixes: 65c93628599d ("bpftool: Add struct_ops support") Signed-off-by: Yichong Chen <chenyichong@uniontech.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Link: https://lore.kernel.org/bpf/9F9017160ABE125F+20260624025055.1574875-3-chenyichong@uniontech.com
Diffstat (limited to 'tools/bpf')
-rw-r--r--tools/bpf/bpftool/struct_ops.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/struct_ops.c b/tools/bpf/bpftool/struct_ops.c
index aa43dead249c..835e5e561f7f 100644
--- a/tools/bpf/bpftool/struct_ops.c
+++ b/tools/bpf/bpftool/struct_ops.c
@@ -643,6 +643,10 @@ int do_struct_ops(int argc, char **argv)
err = cmd_select(cmds, argc, argv, do_help);
btf__free(btf_vmlinux);
+ btf_vmlinux = NULL;
+ map_info_type = NULL;
+ map_info_alloc_len = 0;
+ map_info_type_id = 0;
return err;
}