diff options
author | Wei Fu <fuweid89@gmail.com> | 2022-01-08 16:40:08 +0800 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-01-12 17:01:38 -0800 |
commit | 0991f6a38f576aa9a5e34713e23c998a3310d4d0 (patch) | |
tree | 6a547d61b2ad8701c2ecca39b6887306bfb834d8 /samples | |
parent | a32ea51a3f17ce6524c9fc19d311e708331c8b5f (diff) | |
download | linux-0991f6a38f576aa9a5e34713e23c998a3310d4d0.tar.gz linux-0991f6a38f576aa9a5e34713e23c998a3310d4d0.tar.bz2 linux-0991f6a38f576aa9a5e34713e23c998a3310d4d0.zip |
bpftool: Only set obj->skeleton on complete success
After `bpftool gen skeleton`, the ${bpf_app}.skel.h will provide that
${bpf_app_name}__open helper to load bpf. If there is some error
like ENOMEM, the ${bpf_app_name}__open will rollback(free) the allocated
object, including `bpf_object_skeleton`.
Since the ${bpf_app_name}__create_skeleton set the obj->skeleton first
and not rollback it when error, it will cause double-free in
${bpf_app_name}__destory at ${bpf_app_name}__open. Therefore, we should
set the obj->skeleton before return 0;
Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
Signed-off-by: Wei Fu <fuweid89@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220108084008.1053111-1-fuweid89@gmail.com
Diffstat (limited to 'samples')
0 files changed, 0 insertions, 0 deletions