]> git.baikalelectronics.ru Git - kernel.git/commit
libbf: Fix uninitialized pointer at btf__parse_raw()
authorDaniel T. Lee <danieltimlee@gmail.com>
Wed, 5 Aug 2020 22:33:59 +0000 (07:33 +0900)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 6 Aug 2020 23:47:00 +0000 (16:47 -0700)
commitf298ddb7ef2f92509d4ae4ef662dea4d43837e0b
tree6e3d312032e3716fed044334c235458d93d79bab
parent8096a81456be1a6c09379d061b691cb4527b6909
libbf: Fix uninitialized pointer at btf__parse_raw()

Recently, from commit d1714140867a ("libbpf: Add btf__parse_raw() and
generic btf__parse() APIs"), new API has been added to libbpf that
allows to parse BTF from raw data file (btf__parse_raw()).

The commit derives build failure of samples/bpf due to improper access
of uninitialized pointer at btf_parse_raw().

    btf.c: In function btf__parse_raw:
    btf.c:625:28: error: btf may be used uninitialized in this function
      625 |  return err ? ERR_PTR(err) : btf;
          |         ~~~~~~~~~~~~~~~~~~~^~~~~

This commit fixes the build failure of samples/bpf by adding code of
initializing btf pointer as NULL.

Fixes: d1714140867a ("libbpf: Add btf__parse_raw() and generic btf__parse() APIs")
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200805223359.32109-1-danieltimlee@gmail.com
tools/lib/bpf/btf.c