[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202112011647.lhISTWxn-lkp@intel.com>
Date: Wed, 1 Dec 2021 12:58:30 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: kbuild@...ts.01.org, Alexei Starovoitov <ast@...nel.org>
Cc: lkp@...el.com, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org
Subject: [kbuild] [ast-bpf:relo_core 14/23] kernel/bpf/btf.c:6646
bpf_core_find_cands() error: uninitialized symbol 'main_btf'.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git relo_core
head: 65afd07f07d266a2b060ab282d72a8d49e0f9eaf
commit: 11b37572bb5db757ca09de550c38471c995d0f50 [14/23] bpf: Add bpf_core_add_cands() and wire it into bpf_core_apply_relo_insn().
config: i386-randconfig-m021-20211128 (https://download.01.org/0day-ci/archive/20211201/202112011647.lhISTWxn-lkp@intel.com/config )
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
smatch warnings:
kernel/bpf/btf.c:6646 bpf_core_find_cands() error: uninitialized symbol 'main_btf'.
vim +/main_btf +6646 kernel/bpf/btf.c
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6574 static struct bpf_cand_cache *
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6575 bpf_core_find_cands(struct bpf_core_ctx *ctx, u32 local_type_id)
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6576 {
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6577 const struct btf *local_btf = ctx->btf;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6578 const struct btf_type *local_type;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6579 const struct btf *main_btf;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6580 size_t local_essent_len;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6581 struct bpf_cand_cache *cands, *cc;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6582 struct btf *mod_btf;
^^^^^^^^^^^^^^^^^^^^
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6583 const char *name;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6584 int id;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6585
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6586 local_type = btf_type_by_id(local_btf, local_type_id);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6587 if (!local_type)
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6588 return ERR_PTR(-EINVAL);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6589
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6590 name = btf_name_by_offset(local_btf, local_type->name_off);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6591 if (str_is_empty(name))
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6592 return ERR_PTR(-EINVAL);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6593 local_essent_len = bpf_core_essential_name_len(name);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6594
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6595 cands = kcalloc(1, sizeof(*cands), GFP_KERNEL);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6596 if (!cands)
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6597 return ERR_PTR(-ENOMEM);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6598 cands->name = kmemdup_nul(name, local_essent_len, GFP_KERNEL);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6599 if (!cands->name) {
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6600 kfree(cands);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6601 return ERR_PTR(-ENOMEM);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6602 }
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6603 cands->kind = btf_kind(local_type);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6604 cands->name_len = local_essent_len;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6605
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6606 cc = check_cand_cache(cands, vmlinux_cand_cache, VMLINUX_CAND_CACHE_SIZE);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6607 if (cc) {
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6608 if (cc->cnt) {
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6609 bpf_free_cands(cands);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6610 return cc;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6611 }
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6612 goto check_modules;
^^^^^^^^^^^^^^^^^^^
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6613 }
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6614
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6615 /* Attempt to find target candidates in vmlinux BTF first */
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6616 main_btf = bpf_get_btf_vmlinux();
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6617 cands = bpf_core_add_cands(cands, main_btf, 1);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6618 if (IS_ERR(cands))
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6619 return cands;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6620
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6621 /* populate cache even when cands->cnt == 0 */
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6622 populate_cand_cache(cands, vmlinux_cand_cache, VMLINUX_CAND_CACHE_SIZE);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6623
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6624 /* if vmlinux BTF has any candidate, don't go for module BTFs */
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6625 if (cands->cnt)
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6626 return cands;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6627
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6628 check_modules:
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6629 cc = check_cand_cache(cands, module_cand_cache, MODULE_CAND_CACHE_SIZE);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6630 if (cc) {
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6631 bpf_free_cands(cands);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6632 /* if cache has it return it even if cc->cnt == 0 */
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6633 return cc;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6634 }
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6635
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6636 /* If candidate is not found in vmlinux's BTF then search in module's BTFs */
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6637 spin_lock_bh(&btf_idr_lock);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6638 idr_for_each_entry(&btf_idr, mod_btf, id) {
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6639 if (!btf_is_module(mod_btf))
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6640 continue;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6641 /* linear search could be slow hence unlock/lock
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6642 * the IDR to avoiding holding it for too long
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6643 */
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6644 btf_get(mod_btf);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6645 spin_unlock_bh(&btf_idr_lock);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 @6646 cands = bpf_core_add_cands(cands, mod_btf, btf_nr_types(main_btf));
^^^^^^^^
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6647 if (IS_ERR(cands)) {
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6648 btf_put(mod_btf);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6649 return cands;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6650 }
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6651 spin_lock_bh(&btf_idr_lock);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6652 btf_put(mod_btf);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6653 }
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6654 spin_unlock_bh(&btf_idr_lock);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6655 /* populate cache even when cands->cnt == 0 */
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6656 populate_cand_cache(cands, module_cand_cache, MODULE_CAND_CACHE_SIZE);
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6657 return cands;
11b37572bb5db7 Alexei Starovoitov 2021-09-16 6658 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
_______________________________________________
kbuild mailing list -- kbuild@...ts.01.org
To unsubscribe send an email to kbuild-leave@...ts.01.org
Powered by blists - more mailing lists