tools: libbpf: handle NULL program gracefully in bpf_program__nth_fd()
authorJakub Kicinski <jakub.kicinski@netronome.com>
Thu, 26 Jul 2018 21:32:18 +0000 (14:32 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 27 Jul 2018 05:18:44 +0000 (07:18 +0200)
commit1e960043e8ae65d6f53b3414586a3fb634461908
tree7fe3914c4ce7da570106058da6d6a32007fd702f
parent2367bd99f62bd952fea5c534eeb1d84c113da38e
tools: libbpf: handle NULL program gracefully in bpf_program__nth_fd()

bpf_map__fd() handles NULL map gracefully and returns -EINVAL.
bpf_program__fd() and bpf_program__nth_fd() crash in this case.
Make the behaviour more consistent by validating prog pointer
as well.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/lib/bpf/libbpf.c