On Fri, Jun 23, 2023 at 10:12:45AM +0800, Jackie Liu wrote: SNIP > + > +static void kprobe_multi_resolve_free(struct kprobe_multi_resolve *res) > +{ > + free(res->addrs); > + > + /* reset to zero, when fallback */ > + res->cap = 0; > + res->cnt = 0; > + res->addrs = NULL; > +} > + > struct bpf_link * > bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog, > const char *pattern, > @@ -10477,9 +10539,16 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog, > return libbpf_err_ptr(-EINVAL); > > if (pattern) { > - err = libbpf_kallsyms_parse(resolve_kprobe_multi_cb, &res); > - if (err) > - goto error; > + err = libbpf_available_kprobes_parse(ftrace_resolve_kprobe_multi_cb, > + &res); > + if (err) { > + /* fallback to kallsyms */ > + kprobe_multi_resolve_free(&res); > + err = libbpf_kallsyms_parse(kallsyms_resolve_kprobe_multi_cb, > + &res); > + if (err) > + goto error; > + } > if (!res.cnt) { > err = -ENOENT; > goto error; > @@ -10512,12 +10581,12 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog, > goto error; > } > link->fd = link_fd; > - free(res.addrs); > + kprobe_multi_resolve_free(&res); we don't need to zero res in here, so we could just leave the original free(res.addrs) in here and perhaps rename kprobe_multi_resolve_free to kprobe_multi_resolve_reinit thanks, jirka > return link; > > error: > free(link); > - free(res.addrs); > + kprobe_multi_resolve_free(&res); > return libbpf_err_ptr(err); > } > > -- > 2.25.1 >