bpf, libbpf: fix segfault in bpf_object__init_maps' pr_debug statement
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 23 Apr 2019 22:45:57 +0000 (00:45 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 25 Apr 2019 20:47:29 +0000 (13:47 -0700)
commit4f8827d2b61ed32133e51f6a782bb69d80c7c3d4
tree2f161816188f7f305cc44ceea74afcf32ecc7b42
parent8837fe5dd09bd0331b3e2d1b6e400b7fcda8963a
bpf, libbpf: fix segfault in bpf_object__init_maps' pr_debug statement

Ran into it while testing; in bpf_object__init_maps() data can be NULL
in the case where no map section is present. Therefore we simply cannot
access data->d_size before NULL test. Move the pr_debug() where it's
safe to access.

Fixes: d859900c4c56 ("bpf, libbpf: support global data/bss/rodata sections")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/libbpf.c