diff options
author | wangpei <81410079+wangpei-nice@users.noreply.github.com> | 2021-05-29 00:08:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-28 16:08:47 +0000 |
commit | 19acfc90667e81a00b54909db594819441a18541 (patch) | |
tree | 9aab97eb48db575c21944be0b8b7ccba17c4b6d1 /collectors/ebpf.plugin/ebpf_dcstat.c | |
parent | 045759ab980097848eaed2a68357a45464026758 (diff) |
fix ebpf.plugin segfault when ebpf_load_program return null pointer (#11203)
Diffstat (limited to 'collectors/ebpf.plugin/ebpf_dcstat.c')
-rw-r--r-- | collectors/ebpf.plugin/ebpf_dcstat.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/collectors/ebpf.plugin/ebpf_dcstat.c b/collectors/ebpf.plugin/ebpf_dcstat.c index 9692aa1f17..4fcfc16741 100644 --- a/collectors/ebpf.plugin/ebpf_dcstat.c +++ b/collectors/ebpf.plugin/ebpf_dcstat.c @@ -122,13 +122,15 @@ static void ebpf_dcstat_cleanup(void *ptr) ebpf_dcstat_clean_names(); - struct bpf_program *prog; - size_t i = 0 ; - bpf_object__for_each_program(prog, objects) { - bpf_link__destroy(probe_links[i]); - i++; + if (probe_links) { + struct bpf_program *prog; + size_t i = 0 ; + bpf_object__for_each_program(prog, objects) { + bpf_link__destroy(probe_links[i]); + i++; + } + bpf_object__close(objects); } - bpf_object__close(objects); } /***************************************************************** |