diff options
author | Andrii Nakryiko <andriin@fb.com> | 2020-07-29 16:21:48 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2020-07-31 00:53:07 +0200 |
commit | 50450fc716c1a570ee8d8bfe198ef5d3cfca36e4 (patch) | |
tree | 081623f21697f9919d3120b820ddea93f776ceab /net/ipv4 | |
parent | a6599abdeac30063baf89df166068b20758e0e86 (diff) |
libbpf: Make destructors more robust by handling ERR_PTR(err) cases
Most of libbpf "constructors" on failure return ERR_PTR(err) result encoded as
a pointer. It's a common mistake to eventually pass such malformed pointers
into xxx__destroy()/xxx__free() "destructors". So instead of fixing up
clean up code in selftests and user programs, handle such error pointers in
destructors themselves. This works beautifully for NULL pointers passed to
destructors, so might as well just work for error pointers.
Suggested-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20200729232148.896125-1-andriin@fb.com
Diffstat (limited to 'net/ipv4')
0 files changed, 0 insertions, 0 deletions