On Fri, Apr 10, 2020 at 11:06:12AM +0900, Daniel T. Lee wrote: > From commit 65c93628599d ("bpftool: Add struct_ops support"), > a new type of command struct_ops has been added. > > This command requires kernel CONFIG_DEBUG_INFO_BTF=y, and for retrieving > btf info, get_btf_vmlinux() is used. > > When running this command on kernel without BTF debug info, this will > lead to 'btf_vmlinux' variable contains invalid(error) pointer. And by > this, btf_free() causes a segfault when executing 'bpftool struct_ops'. > > This commit adds pointer validation with IS_ERR not to free invalid > pointer, and this will fix the segfault issue. > > Signed-off-by: Daniel T. Lee <danieltimlee@xxxxxxxxx> Fixes: 65c93628599d ("bpftool: Add struct_ops support") Acked-by: Martin KaFai Lau Thanks for the fix! Please add the Fixes tag in the future.