From: Zbigniew Jędrzejewski-Szmek Date: Sun, 9 Jan 2022 18:53:22 +0000 (+0100) Subject: bpf: adjust comment about not calling sym_bpf_link__destroy X-Git-Tag: v251-rc1~556^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d179b8d3683a38e1fa591b0079851ce2aff7d7dd;p=thirdparty%2Fsystemd.git bpf: adjust comment about not calling sym_bpf_link__destroy --- diff --git a/src/shared/bpf-link.c b/src/shared/bpf-link.c index 85eab090328..fea49b2ecbb 100644 --- a/src/shared/bpf-link.c +++ b/src/shared/bpf-link.c @@ -32,12 +32,12 @@ int bpf_serialize_link(FILE *f, FDSet *fds, const char *key, struct bpf_link *li } struct bpf_link *bpf_link_free(struct bpf_link *link) { - - /* Avoid a useless dlopen() if link == NULL */ - if (!link) - return NULL; - - (void) sym_bpf_link__destroy(link); + /* If libbpf wasn't dlopen()ed, sym_bpf_link__destroy might be unresolved (NULL), so let's not try to + * call it if link is NULL. link might also be a non-null "error pointer", but such a value can only + * originate from a call to libbpf, but that means that libbpf is available, and we can let + * bpf_link__destroy() handle it. */ + if (link) + (void) sym_bpf_link__destroy(link); return NULL; }