On Wed, Jul 29, 2020 at 4:22 PM Andrii Nakryiko <andriin@xxxxxx> wrote: > > 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@xxxxxx> > Signed-off-by: Andrii Nakryiko <andriin@xxxxxx> Acked-by: Song Liu <songliubraving@xxxxxx>