libbpf: Cleanup the legacy uprobe_event on failed add/attach_event()
authorChuang Wang <nashuiliang@gmail.com>
Wed, 29 Jun 2022 15:18:47 +0000 (23:18 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 6 Jul 2022 04:23:03 +0000 (21:23 -0700)
commit2655144fb49bae26eae038c6d056f824a7db2726
tree777cb0284845c78e21a0d861a5b1eab6e54f73c2
parent5666fc997ccb93859ea1d4437936c64c6d75c060
libbpf: Cleanup the legacy uprobe_event on failed add/attach_event()

A potential scenario, when an error is returned after
add_uprobe_event_legacy() in perf_event_uprobe_open_legacy(), or
bpf_program__attach_perf_event_opts() in
bpf_program__attach_uprobe_opts() returns an error, the uprobe_event
that was previously created is not cleaned.

So, with this patch, when an error is returned, fix this by adding
remove_uprobe_event_legacy()

Signed-off-by: Chuang Wang <nashuiliang@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220629151848.65587-4-nashuiliang@gmail.com
tools/lib/bpf/libbpf.c